一般我们在做启动页或者引导页的时候只显示一张图片,心想这还不是so easy!一个ImageView设置一张图片解决。
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@mipmap/screen1"/>
运行后发现图片并没有全屏。嘿嘿 那也难不倒我。
记得有一个fitXY可以将图片布满全屏啊。搬过来
android:scaleType="fitXY"
运行看效果。嗯! 全屏了。但是图片却被拉伸了 (开始挠头。。。)
通过一顿百度谷歌发现还有一个adjustViewBounds的属性,搬过来试试
android:adjustViewBounds="true"
咦 居然好了!!开心到飞起 (本来想配图的 但是没找到那个图片 哈哈)
stop! 高心太早了,看效果好像是没有任何变化,图片还是被拉伸了。
好了 亮出最后的大招吧
需要将ImageView的高度设置为wrap_content
如下:
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:src="@mipmap/screen1"/>