右側に揃えたいテキストと画像を含む、同じサイズの 2 つの RelativeLayouts があります。ただし、これを指定したことはありませんが、右側に配置できないある種のパディングがあるようです。
これが私のコードです:
<LinearLayout
android:baselineAligned="false"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RelativeLayout
android:id="@+id/my_relativelayout"
android:background="@drawable/my_background"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="right">
<TextView
android:id="@+id/my_textview"
android:textAppearance="?android:attr/textAppearanceButton"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<ImageView
android:id="@+id/my_imageview"
android:layout_centerVertical="true"
android:scaleType="center"
android:src="@drawable/my_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/my_textview">
</ImageView>
</RelativeLayout>
<RelativeLayout
... same thing here ...>
</RelativeLayout>
</LinearLayout>
編集:空のスペースは他のRelativeLayoutではありません。もう 1 つの RelativeLayout は、テキストと画像を含む別の「青い四角形」であり、右側のスペースの問題も発生しています。そのようです: