我试图创建下面的布局,我有一些困难:如何对齐第一个元素填充所有可用空间的2个元素?
的困难是获得左侧的Button
填写所有不是由所占用的可用空间右边的ImageButton
。
这是我使用的axml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical">
<LinearLayout
android:id="@+id/layout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:background="@null"
android:text="The Button Text"
android:id="@+id/btnText"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
<ImageButton
android:id="@+id/imgSettings"
android:layout_toRightOf="@id/layout1"
android:background="@null"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="@drawable/settings_light"
android:layout_centerVertical="true" />
</RelativeLayout>
,它的出现是这样的:
我如何能得到这个显示为第一个图像中概述?
我知道有一种方法可以通过编辑XML来完成它,但有时我发现自己忘记了使用Eclipse ADT进行可视化编辑是相当不错的。因此,请尝试使用鼠标拉视图以适应可用空间。它通常会创建正确的代码。 –