ビューの幅を画面の幅の 50% に設定し、このビューを水平方向に中央に配置する必要がありますが、画面の左側または右側に 1 つ以上のボタンが取り付けられている可能性があります。
RL の左端または右端に取り付けられた LL の上にボタンを配置しながら、50% を中央に配置するためにウェイトを使用して線形レイアウトを配置できるように、相対レイアウトを使用しています。ただし、このレイアウトには青い中央のバーがありません。中央のビューの layout_weight を 1 に設定すると、3 つの同じサイズのバーが表示されます。
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="48dp">
<LinearLayout
android:id="@+id/stupid_android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<View
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="#FF0000"
android:layout_weight="1" />
<View
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="#0000FF"
android:layout_weight="2" />
<View
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="#00FF00"
android:layout_weight="1" />
</LinearLayout>
</RelativeLayout>