android - ImageView 适合而不拉伸(stretch)图像

标签 android android-layout uiimageview imageview

我的 ImageView 是否有可能适合所有屏幕尺寸而不会拉伸(stretch)图像?

我尝试使用 fill_parent > wrap_content

将所有比例类型更改为背景和 src

但仍然。如果图像不小,它看起来只是被拉伸(stretch)了..

示例:

<ImageView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:scaleType="centerInside"
    android:adjustViewBounds="true"
    android:background="@drawable/background" />

<ImageView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:scaleType="fitXY"
    android:adjustViewBounds="true"
    android:background="@drawable/background" />

这 2 个适合宽度,但图像被拉伸(stretch).. 但是当我将其更改为 src 时,图像只是居中且很小。

最佳答案

没有内置的缩放类型允许 ImageView 自动放大图像保持其纵横比不变。进行放大的唯一比例类型是 fitXY,它不会尊重纵横比,正如您自己发现的那样。

话虽如此,这个话题已经被访问过不止一次了。查看针对类似问题提出的一些建议:

我肯定会更多,因此可能值得使用顶部的搜索框。

关于android - ImageView 适合而不拉伸(stretch)图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13925530/

相关文章:

android - 协调器布局和运动布局有什么区别?

android - ExoPlayer 根据 URL 使用哪个 MediaSource

Android - 想优化Layout

android - 设置 ScrollView 权重使 View 不显示

Android 自定义可跨越字符串的组合跨度

android - 不是从 Intent 开始 Activity

java - findViewById 在 onCreate 方法中给出 NullPointer 异常

ios - 模糊 UIImage 不剪裁(Swift)

iOS:通过按 UIButton 更改 UIImageView

ios - 表格 View 单元格中的 Storyboard ImageView