繁体   English   中英

Android imageview,缩放全屏和centerCrop

[英]Android imageview, scale full screen, and centerCrop

如何使用图像填充屏幕的图像视图,但保持其纵横比,并适合中心?

目前我有大图像,大于手机屏幕分辨率,但我怀疑它们将被装在具有更高分辨率的设备上

scaleType哪种组合可以scaleType

您可以简单地使用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" />
<ImageView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:scaleType="fitCenter" />

这是一个基本设置。

我之前遇到过这个问题,问题是当图像需要按比例放大(屏幕宽度大于图像)时,Android不会将图像缩放到超出给定大小的范围。 但是,按比例缩小效果很好。

我最终创建了下面提到的AspectRatioImageView ,效果很好。 请务必阅读有关getIntrinsicWidth()返回0和getDrawable()返回null的注释,并对其进行一些安全检查。

如何在屏幕上拉伸三个图像以保持纵横比?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM