Android 在具有Linearlayout的Framelayout中将图元放置在其他图元下方

Android 在具有Linearlayout的Framelayout中将图元放置在其他图元下方,android,xml,android-layout,Android,Xml,Android Layout,我为我的一些屏幕创建了一个android布局xml,显然我在我的应用程序中使用了一个导航抽屉,这就是我使用框架布局的原因。现在,我添加了一个线性布局,将显示以下内容: 带有提交按钮的文本视图 2个图像按钮 这是我想要的布局示例: 问题是,当我制作布局时,我似乎无法拉下2个按钮使其位于提交下方,因为发生的情况是两个按钮都位于布局的右侧,如下所示: 这是我的xml代码: <android.support.v4.widget.DrawerLayout xmlns:android="http:

我为我的一些屏幕创建了一个android布局xml,显然我在我的应用程序中使用了一个导航抽屉,这就是我使用框架布局的原因。现在,我添加了一个线性布局,将显示以下内容:

带有提交按钮的文本视图

2个图像按钮

这是我想要的布局示例:

问题是,当我制作布局时,我似乎无法拉下2个按钮使其位于提交下方,因为发生的情况是两个按钮都位于布局的右侧,如下所示:

这是我的xml代码:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="mypackage.test.HomeActivity" >

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

        <LinearLayout 
            android:id="@+id/linerlayout"
            android:layout_width="match_parent"
            android:layout_height="100dp"
              android:gravity="center_horizontal"

            >
                    <EditText
            android:id="@+id/editText1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="10"
            android:hint="Enter ID"
            >

            <requestFocus />
        </EditText>

            <Button
                android:id="@+id/button1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Submit" /> 
         <!--
        I'm trying to put the two buttons here but what happens is they both disappear when I put them

        -->      

        <Button
            android:id="@+id/button2"
            android:text="Button"
 android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

        <Button
            android:id="@+id/button3"
            android:text="Button" 
 android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>          
        </LinearLayout>

        </FrameLayout>

    <fragment
        android:id="@+id/navigation_drawer"
        android:name="mypackage.test.NavigationDrawerFragment"
        android:layout_width="@dimen/navigation_drawer_width"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        tools:layout="@layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>


我怎样才能按下这两个按钮?是否要将按钮转移到另一个布局?

您可以将另外两个按钮放置在LinearLayout布局之外,以便它们 将显示在底部。像这样:

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

    <LinearLayout
        android:id="@+id/linerlayout"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:gravity="center_horizontal"

        >
        <EditText
            android:id="@+id/editText1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="10"
            android:hint="Enter ID"
            >
        <requestFocus />
        </EditText>
        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Submit" />

    </LinearLayout>

    <Button
        android:id="@+id/button3"
        android:text="Button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right|bottom"/>

    <Button
        android:id="@+id/button2"
        android:text="Button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right|center_vertical"/>

</FrameLayout>



我尝试将它们放置在外部,但这会导致框架布局中的所有其他元素都不合适。请使用我在Android Studio中尝试时发布的代码,看起来还可以。我明白了。我试着在不检查全部代码的情况下移动我的。我现在就要测试它。测试过了,现在可以工作了。我知道你只需要给按钮增加重力,让它们去你想去的地方。谢谢
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="mypackage.test.HomeActivity">

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

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <EditText
                android:id="@+id/editText1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_toLeftOf="@+id/button1"
                android:ems="10"
                android:hint="Enter ID">

                <requestFocus />
            </EditText>

            <Button
                android:id="@+id/button1"
                android:layout_width="wrap_content"
                android:layout_height="48dp"
                android:layout_alignParentRight="true"
                android:text="Submit" />


            <Button
                android:id="@+id/button3"
                android:text="Button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/editText1"
                android:layout_alignRight="@+id/editText1" />

            <Button
                android:id="@+id/button2"
                android:text="Button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/button3"
                android:layout_alignRight="@+id/button3" />
        </RelativeLayout>
    </FrameLayout>

    <fragment
        android:id="@+id/navigation_drawer"
        android:layout_width="@dimen/navigation_drawer_width"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        tools:layout="@layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>