我正在构建一个需要进行布局的应用程序。通常我使用相对布局和自定义视图来完成我的工作,但是这一次,我想使用线性布局,所以我在 XML 下制作了这个。我的目标是在父级内部创建一个子级线性布局,并将子级的重力设置为“底部”,这将保持我的两个底部,一个应该右对齐,一个应该左对齐。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:gravity="bottom"
>
<Button
android:gravity="left"
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Previous" />
<Button
android:id="@+id/button3"
android:layout_gravity="right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Next"/>
</LinearLayout>
孩子坐在底部,但是按钮的两个视图没有正确对齐。我是不是做错了什么,或者这些事情不能通过这个Layout来实现?