图片 'fill' 不同版本 Android 的 ImageView 不同?
Images 'fill' ImageViews differently on different versions of Android?
不确定如何正确命名它,但本质上我的图像在 Android 的不同版本之间以不同方式填充它们的 ImageViews。
示例:
从左边开始是 4.1.1、4.4.4 和 5.0.0。全部在同一台设备 (Nexus 4) 上。
KitKat 和 Lollipop 符合预期,但无论我做什么,无论屏幕密度如何,Jellybean 都无法效仿。
我使用 Picasso 加载图像,使用 RecyclerView/CardView 组合加载列表。
代码没有什么特别之处,就 Picasso 而言是相当标准的,但如果有人需要,这里是 ImageView 的 XML:
<ImageView
android:id="@+id/news_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/news_image_content_description"
android:scaleType="fitCenter"
android:cropToPadding="false"
android:adjustViewBounds="true"/>
终于想通了。正如我在那条评论中提到的,pre-API 17 它不会让可绘制对象增长以填充 ImageView,只会缩小。所以我的解决方案是使用 Picasso 来放大图像并让系统根据这个 SO post
的观察结果缩小它的大小
不确定如何正确命名它,但本质上我的图像在 Android 的不同版本之间以不同方式填充它们的 ImageViews。
示例:
从左边开始是 4.1.1、4.4.4 和 5.0.0。全部在同一台设备 (Nexus 4) 上。
KitKat 和 Lollipop 符合预期,但无论我做什么,无论屏幕密度如何,Jellybean 都无法效仿。
我使用 Picasso 加载图像,使用 RecyclerView/CardView 组合加载列表。
代码没有什么特别之处,就 Picasso 而言是相当标准的,但如果有人需要,这里是 ImageView 的 XML:
<ImageView
android:id="@+id/news_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/news_image_content_description"
android:scaleType="fitCenter"
android:cropToPadding="false"
android:adjustViewBounds="true"/>
终于想通了。正如我在那条评论中提到的,pre-API 17 它不会让可绘制对象增长以填充 ImageView,只会缩小。所以我的解决方案是使用 Picasso 来放大图像并让系统根据这个 SO post
的观察结果缩小它的大小