[英]RelativeLayout - positioning a View under a ViewGroup
I have the following structure defined in an xml layout file. 我在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>
The FrameLayout is positioned correctly in the center of its parent. FrameLayout正确放置在其父级的中心。 But the Button isn't getting positioned under it.
但是Button并没有定位在按钮下方。 Instead it's displaying in the top left corner.
相反,它显示在左上角。
Am I doing something incorrectly or is this a bug with RelativeLayout? 我是在做错什么,还是RelativeLayout的错误?
How have you checked whether frame layout is in the center of parent or not ? 您如何检查框架布局是否位于父项的中心?
Try adding some view inside frame layout or give some fix height and width to it. 尝试在框架布局内添加一些视图,或为其提供一些固定的高度和宽度。 It might solve the problem.
它可能会解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.