3つのLinearLayoutsを整理しようとしています.1つは左に、もう1つは右に、3つ目は両側に同じ量の空白を置きます。私は、これを達成するためにこれらをRelativeLayoutにラップすると思います。次に、レイアウトをalignParentLeftに、2番目のレイアウトをalignParentRightに設定します。しかし、3番目のレイアウトでは、layout_marginLeft =(RelativeLayout.width - (layout1.width + layout2.width + layout3.width))/ 2を設定したいと思います。しかし、私はxmlでこれを行う方法がわかりません。助言がありますか?Android:RelativeLayout内のコンポーネントを均等に配置しますか?
*編集。提案に基づいて、私は現在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>
だけLinearLayout(LinearLayout内の3つのLinearLayout)に行き、すべての幅をfill_parentに設定し、内側の3つのレイアウトに 'android:layout_weight =" 1 "'を付けます。 – kcoppock
ありがとう、これは私を近づけてくれましたが、私のためにはうまくいきません。これにより、3つの線形レイアウトがすべて同じサイズに強制されますが、私の線形レイアウトは異なる内容になります。私の編集を見てください。 – ab11
3つのボタンがあり、3つのボタンの幅が同じではないと思います。これは難しいケースです。私はすべてのボタンがよく見えるように画像のサイズを小さくすることをお勧めします。例えばtwitter/facebookアプリを見てください。それが不可能な場合は、各ボタンの最小幅を決定し、それらを指定してください[画面サイズにも依存します]。それ以降、私はあなたの周りを遊んで、あなたにとって何が最善のものかを見極めることを提案することができます。 – achie