【发布时间】:2017-07-14 20:40:08
【问题描述】:
在RecyclerView 中,图像显示为全高和全宽,并且没有拉伸,这可能吗?
【问题讨论】:
标签: android image bitmap imageview
在RecyclerView 中,图像显示为全高和全宽,并且没有拉伸,这可能吗?
【问题讨论】:
标签: android image bitmap imageview
使用android:scaleType="centerInside"
ImageView.ScaleType CENTER_INSIDE 均匀缩放图像(保持图像的纵横比),使图像的两个尺寸(宽度和高度)都等于或小于视图的相应尺寸(减去填充)。
<ImageView
android:id="@+id/imageView"
android:layout_width="fixed_width_for_each_cell"
android:layout_height="fixed_height_for_each_cell"
android:scaleType="centerInside"
/>
Center Inside 属性不会改变 Image Aspect Ratio 。如果您根据位图Aspect Ratio 为ImageView 提供高度和宽度,则其调整图像大小,因此应该显示其确定的完整图像。
【讨论】:
仅使用 android:scaleType="fitXY"
【讨论】:
试试这个代码
Picasso.with(myContext).load(uri).resize(720, 720)
.centerCrop().into(aImageView);
我认为它对你的情况有用。
【讨论】:
<ImageView
android:id="@+id/imageView"
android:layout_width="fixed_width_for_each_cell"
android:layout_height="fixed_height_for_each_cell"
android:scaleType="fitXY"
android:adjustViewBounds="true"/>
【讨论】:
将此添加到您的 ImageView
android:adjustViewBounds="true"
android:scaleType="centerCrop"
【讨论】: