我正在尝试组织3个LinearLayout,其中一个左对齐,一个右对齐,第三个在两者之间具有相等数量的空白空间。我认为我可以将它们包装在RelativeLayout中来实现这一点。然后将一个布局设置为alignParentLeft,将第二个布局设置为alignParentRight。但是对于第三个布局,我想设置layout_marginLeft =(RelativeLayout.width-(layout1.width + layout2.width + layout3.width))/ 2。虽然我不知道如何在xml中实现这一点。有什么建议吗?
*编辑。根据建议,我现在正在使用LinearLayout。这更接近实现,但是3个布局没有均匀分布,右侧布局没有右对齐。以下是我的xml:
*编辑。根据建议,我现在正在使用LinearLayout。这更接近实现,但是3个布局没有均匀分布,右侧布局没有右对齐。以下是我的xml:
<LinearLayout
android:id="@+id/toolbar"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:paddingTop="4dip"
android:paddingBottom="4dip"
android:background="#50000000"
android:visibility="visible">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content">
<ImageButton
android:id="@+id/open"
android:src="@drawable/open"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageButton>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content">
<ImageButton
android:id="@+id/prev"
android:src="@drawable/prev"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageButton>
<TextView
android:id="@+id/totalpages"
android:text="0 of 0"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFFFF">
</TextView>
<ImageButton
android:id="@+id/next"
android:src="@drawable/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageButton>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_gravity="right"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content">
<ImageButton
android:id="@+id/zoomout"
android:src="@drawable/zoomout"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageButton>
<ImageButton
android:id="@+id/zoomin"
android:src="@drawable/zoomin"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageButton>
</LinearLayout>
</LinearLayout>