1

我有一个LinearLayout包含 6FrameLayout个块的。

在此处输入图像描述

有什么方法可以将所有FrameLayout块集中在父级中LinearLayout?目前,它们位于屏幕的左侧而不是居中。

4

2 回答 2

3

您可以android:layout_gravity="center"在 LinearLayout 和android:gravity="center"FrameLayouts 中使用将它们设置在中心。还有其他选项见链接

于 2013-09-05T06:41:58.143 回答
0

试试这个方法

<?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>
于 2013-09-05T06:41:20.690 回答