Java 在LinearLayout中居中放置多个框架布局
我有一个Java 在LinearLayout中居中放置多个框架布局,java,android,android-layout,android-linearlayout,Java,Android,Android Layout,Android Linearlayout,我有一个LinearLayout,它包含6个FrameLayout块 是否有任何方法可以将父线性布局中的所有帧布局块居中?目前,它们位于屏幕左侧,而不是居中。请尝试这种方式。 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"
LinearLayout
,它包含6个FrameLayout
块
是否有任何方法可以将父
线性布局
中的所有帧布局
块居中?目前,它们位于屏幕左侧,而不是居中。请尝试这种方式。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical"
android:padding="2dp" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</FrameLayout>
</LinearLayout>
您可以在线性布局中使用android:layout\u gravity=“center”
,在框架布局中使用android:gravity=“center”
将它们设置在中心。还有其他选择你说的“中心”是什么意思?你能画一张图片来说明你想要什么吗?想想看。6幅图像显示左对齐。我需要它们在屏幕内居中。