我为我的一些屏幕创建了android layout xml,显然我在我的应用程序中使用了导航抽屉,这就是为什么我使用框架布局。现在,我已经添加了一个线性布局,将显示如下:将元素放置在Framelayout中具有Linearlayout的其他元素下方
有一个文本视图提交按钮
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>
如何拉两个按钮往下走?我应该将按钮转移到另一种布局吗?
我试着将它们放在外面,但它导致所有其他元素的走出去的地方的FrameLayout里面。 – marchemike
请使用我发布的代码,因为我在Android Studio中尝试过,似乎没关系。 –
我明白了。我试图移动我的而不检查整个代码。现在会测试它。 – marchemike