【发布时间】:2015-02-28 17:29:07
【问题描述】:
我有一个 ImageView 固定 layout_height 和 layout_width 和一个在它的背景中的框架(代码如下)。
我想使用 picasso 将图像加载到其中并使图像适合 ImageView 边界。
我的ImageView:
<ImageView
android:id="@+id/upload_photo_row_image"
android:layout_width="99dp"
android:layout_height="72dp"
android:background="@drawable/background_photo_frame"
android:padding="4dp"/>
background_photo_frame:
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@android:color/transparent"/>
<stroke
android:width="4 dp"
android:color="@color/pure_white"/>
</shape>
毕加索加载代码:
Picasso.with(getContext()).load(uri).fit().centerCrop().into(imageView)
毕加索版:
compile 'com.squareup.picasso:picasso:2.5.0'
使用此代码,图像的宽度比应有的要小一些,如下图所示(包含 ViewGroup 的 background_color 已设置为红色以说明错误):
我可以修复这个问题,将属性android:scaleType="fitXY" 添加到我的ImageView。是我做错了什么还是Picasso 中的错误?
【问题讨论】:
标签: android imageview scale picasso