RelativeLayout - 将视图定位在ViewGroup下

时间:2010-04-23 03:39:31

标签: android

我在xml布局文件中定义了以下结构。

<RelativeLayout android:id="@+id/mainLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<FrameLayout android:id="@+id/frame" android:layout_centerInParent="true" android:layout_width="wrap_content" android:layout_height="wrap_content" ></FrameLayout>
<Button android:id="@+id/button" android:layout_below="@id/frame" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</RelativeLayout>

FrameLayout正确定位在其父级的中心。但是Button并没有定位在它之下。相反,它显示在左上角。

我做错了什么或者这是RelativeLayout的错误?

1 个答案:

答案 0 :(得分:0)

您如何检查框架布局是否位于父级的中心?

尝试在框架布局中添加一些视图或为其提供一些修复高度和宽度。它可能会解决问题。