【发布时间】:2021-04-13 07:45:56
【问题描述】:
不知道如何正确命名它,但基本上我的图像在不同版本的 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"/>
【问题讨论】:
-
一时兴起,我检查了开发文档并在
adjustViewBounds下找到了这个:“如果应用程序的目标 API 级别为 17 或更低,adjustViewBounds 将允许可绘制对象缩小视图边界,但是在所有情况下都不会增长以填充可用的测量空间。“我想我已经找到了问题,但仍在努力寻找解决方案。