2

Androidで次の構成の画像を表示するにはどうすればよいですか?

  • 元のアスペクト比を保持します(画像は拡大縮小できますが、引き伸ばすことはできません)
  • 親の幅を埋める
  • 親の下部に配置

以下は機能しません。

<ImageView
android:layout_width="fill_parent" 
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:layout_alignParentBottom="true"
android:src="@drawable/background" />

上記のxmlを使用すると、ImageViewは親の幅を取りますが、ImageView内の画像は取りません。

4

1 に答える 1

0

いくつかのポイント。fitCenter の代わりに縦横比を維持したい場合は、centerInsideを試してください:

Scale the image uniformly (maintain the image's aspect ratio) so
that both dimensions (width and height) of the image will be equal
to or less than the corresponding dimension of the view (minus padding). 

アプリケーションを使用するデバイスの画面サイズは異なる場合があることに注意してください。背景画像が伸縮可能なものである場合は、NinePatchDrawableを試すことをお勧めします

于 2010-11-15T11:30:06.120 に答える