如果您想使用的LinearLayout的子视图(按钮)的父母,并希望有在双面角落都按钮,然后像下面代码更新:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/back_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:text="@string/hello_world"
android:contentDescription="LeaveReq_back_button" />
<View android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1"/>
<Button
android:id="@+id/logout_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="logout_button"
android:gravity="right" />
</LinearLayout>
如果允许使用的LinearLayout到RelativeLayout的更新父那么你可以像下面这样更新它:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/back_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="@drawable/new_back_button"
android:contentDescription="@string/LeaveReq_back_button" />
<Button
android:id="@+id/logout_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/back_button"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:background="@drawable/logout"
android:contentDescription="@string/logout_button" />
</RelativeLayout>
现在它取决于你,你如何使用它。
享受编码... :)
查看我的回答低于 – 2015-02-23 10:25:58