java如何在RelativeLayout中使框架布局底部的按钮居中
这是我的xml代码:
<LinearLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
安卓:orientation="vertical">
<FrameLayout
安卓:id="@+id/nero"
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content" />
<RelativeLayout
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_gravity="center"
安卓:orientation="vertical">
<Button
安卓:layout_width="130dp"
安卓:layout_height="130dp" />
....
</RelativeLayout>
<FrameLayout
安卓:id="@+id/imprint"
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:layout_gravity="bottom|center_horizontal">
<Button
安卓:layout_width="230dp"
安卓:layout_height="230dp" />
</FrameLayout>
</LinearLayout>
我想把FrameLayout放在LinearLayout的底部,FrameLayout中的所有元素都应该居中。我该怎么做
# 1 楼答案
在框架布局中使用布局
同时使用底部边距,使其从底部处于完美位置
# 2 楼答案
要将按钮置于
FrameLayout
的中心,您应该添加:在
Button
或:在
FrameLayout
的内部。顺便说一句,如果Button
是唯一的孩子,你为什么要使用FrameLayout