我有一张图片存储在drawable中,需要作为背景图使用。它需要拉伸以填满整个屏幕。 我知道如何使用Java代码将图片拉伸至全屏,但是在XML中该怎么做呢?
android:scaleType="fitXY"
会拉伸图片以适应ImageView
的全部大小。
<ImageView
android:id="@+id/mImageView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher" />
我更喜欢使用scaleType="centerCrop"。这样图片就不会被拉伸到原始比例之外。