我怎样才能有一个图像视图,它的图像充满屏幕,但保持其纵横比,并适合中心?
目前我有比手机屏幕分辨率更大的图像,但我怀疑它们将在更高分辨率的设备上被信箱
哪种scaleType
组合可以做到这一点?
发布于 2013-01-28 03:29:19
您可以简单地使用adjustViewBounds
值来保持图像的纵横比
<ImageView
android:id="@+id/metallicaImage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:src="@drawable/metallica" />
发布于 2013-08-24 18:45:13
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitCenter" />
这是一个基本的设置。
发布于 2013-01-28 03:38:23
我以前遇到过这种情况,问题是当图像需要放大(屏幕宽度大于图像)时,Android不会将图像缩放到超过其给定大小。但是,缩小规模的效果很好。
我最终创建了下面提到的AspectRatioImageView
,运行良好。请务必阅读有关getIntrinsicWidth()
返回0和getDrawable()
返回null的评论,并对它们进行一些安全检查。
How to stretch three images across the screen preserving aspect ratio?
https://stackoverflow.com/questions/14554812
复制相似问题