如何将按钮置于相对布局中 FrameLayout 底部的中心

Mad*_*ddy 4 java xml android android-linearlayout

这是我的 xml 代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <FrameLayout
        android:id="@+id/nero"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:orientation="vertical">

        <Button
            android:layout_width="130dp"
            android:layout_height="130dp" />

         ....

    </RelativeLayout>

    <FrameLayout
        android:id="@+id/imprint"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|center_horizontal">

        <Button
            android:layout_width="230dp"
            android:layout_height="230dp" />
    </FrameLayout>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我想将 FrameLayout 放置在 LinearLayout 的底部,并且 FrameLayout 中的所有元素都应该居中。我怎样才能做到这一点?

S. *_*ees 6

框架布局中使用 Layout_Gravity 即可

 android:layout_gravity="bottom|center"
Run Code Online (Sandbox Code Playgroud)

还可以使用底部边距使其位于底部的完美位置。

android:layout_marginBottom="20dp"
Run Code Online (Sandbox Code Playgroud)