1 つの水平方向の LinearLayout に 2 つのボタンがあると、次のようになります。
ボタンの前に「スペース」ウィジェットを追加すると、LinearLayout xml は次のようになります。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2" />
<Button
android:id="@+id/btnFetch"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/button_Fetch" />
<Button
android:id="@+id/btnCancel"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/button_Cancel" />
</LinearLayout>
...ボタンが「右揃え」になっているので、見た目には満足しています。
...しかし、これは「正しい」方法ですか?
アップデート
エミュレート時に、「キャンセル」ボタンのテキストが 2 行に折り返されたので、「行」プロパティを追加し、重み値を調整しました (2、1、1 ではなく、現在は 42、29、29 です)。エミュレート時にちょうどよく見えます。