リストビューの行の私のxmlコードは
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="5"
android:orientation="vertical" >
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp" />
<TextView
android:id="@+id/tv_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="2"
android:gravity="center" >
<ImageView
android:id="@+id/iv_image"
android:layout_width="50dp"
android:layout_height="40dp"
android:background="@drawable/app_icon_17"
android:contentDescription="@string/empty" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="2"
android:gravity="center" >
<Button
android:id="@+id/btn_delete"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/btn_delete_new"
android:focusable="false" />
</LinearLayout>
</LinearLayout>
ID btn_delete の最後のボタンを右揃えにしたい。そして、設計中の「グラフィカルレイアウト」で私が望んでいたように表示されます。しかし、エミュレーターで実行すると、機能しません。
出力を参照してください:
では、なぜ削除ボタンが右揃えにならないのでしょうか?