Android 踩坑Android开发经验谈

Fresco 加载网络图片被裁剪

2017-06-24  本文已影响87人  jfson_土豆

遇到一个Fresco 从网络加载图片,被放大并剪裁掉了而显示不全。百思不得解。
对比了本地图片的尺寸跟网络加载图片的尺寸一致,也不存在图片尺寸问题。

<com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/img_hot_up_rocket"
        android:layout_width="26dp"
        android:layout_height="38dp"
        android:layout_marginLeft="30dip"
        android:layout_marginTop="100dip"
        android:contentDescription="@string/app_name"
        fresco:placeholderImage="@drawable/live_hot_icon"
        />

解决: 查阅了fresco 官方文档后, fresco:actualImageScaleType="fitCenter" 这个属性对SimpleDraweeView 被剪裁bug有效。可能是fresco:placeholderImage占位图的缘故吧。

fix code:

<com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/img_hot_up_rocket"
        android:layout_width="26dp"
        android:layout_height="38dp"
        android:layout_marginLeft="30dip"
        android:layout_marginTop="100dip"
        android:contentDescription="@string/app_name"
        fresco:actualImageScaleType="fitCenter"
        />

PS: 后来得知,同事因为这个奇怪的问题排查了一天。这个坑索性记一下~

上一篇 下一篇

猜你喜欢

热点阅读