如何在 android 方向改变时在中心填充白色 space

how to fill white space at center when orientation changes in android

我开发了一个应用,在父中心有一个fragment,显示的很好。当我改变我的单元格的方向时 phone 一切都调整得很好,但那个片段再次以父为中心。(从屏幕顶部和底部重叠一些项目)我需要它来覆盖可用的白色 space 在屏幕中央。下面是片段的xml。有什么建议吗?

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    tools:context="layout.message"
    android:background="#f5f5dc"
    android:layout_centerInParent="true">

    <!-- TODO: Update blank fragment layout -->

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >
    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="number"
        android:drawableLeft="@mipmap/phone"

        android:id="@+id/editText"
        android:hint="Mobile Number"

        android:layout_centerHorizontal="true"/>

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="numberDecimal"
        android:drawableLeft="@mipmap/amount"

        android:id="@+id/editText2"
        android:layout_below="@+id/editText"
        android:layout_centerHorizontal="true"
        android:hint="Amount to Pay"/>

    <Button
        android:text="Confirm To Send"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/button"
        android:drawableLeft="@mipmap/send"
        android:layout_centerHorizontal="true"
        android:layout_below="@+id/editText2"

        android:background="@drawable/shape"

        />
</RelativeLayout>
</FrameLayout>

既然使用片段,为什么不用两个xml文件呢?一个具有水平属性,另一个具有垂直属性。请参阅下面的代码并创建另一个 xml 文件并将 android:orientation 更改为垂直。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent">

//Your code here

</RelativeLayout>