テキストを表示し、テキストの横に、右側にフロートする必要のある動的な数の画像を表示したいと思います。
それは私が持っているものです:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:padding="7dp"
android:textSize="18sp"
android:textColor="#000"/>
<ImageView
android:id="@+id/icon1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="right"
android:layout_alignParentRight="true"
android:layout_marginTop="10dip"
android:layout_marginRight="6dip"
android:src="@drawable/bus" />
<ImageView
android:id="@+id/icon2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_toLeftOf="@+id/1"
android:layout_marginTop="10dip"
android:layout_marginRight="6dip"
android:src="@drawable/tram" />
</RelativeLayout>
私の問題は、icon1
表示されていない場合(Javaコードで制御している場合)、icon2が右側に表示されなくなることです。text1
参照icon1
が欠落しているため、オーバーレイされました。