【发布时间】:2018-04-13 10:33:37
【问题描述】:
所以我基本上有一种方法可以将一个图像转换为某种形状,然后从我的位图中进行 Drawable。现在有方法加载位图可绘制(setImageDrawable),但已弃用。
所以代码是这样的:
public static Drawable getDrawableFromName(String name, Activity activity) {
int resourceId = activity.getResources().getIdentifier(name, "drawable", activity.getPackageName());
if(resourceId == 0) {
return null;
} else {
Bitmap croppedIcon = cropImage(activity, resourceId);
if(croppedIcon == null)
return null;
return new BitmapDrawable(activity.getResources(), croppedIcon);
}
}
cropImage 返回具有一些自定义形状的位图图像。
我现在应该如何将这个可绘制对象加载到 Fresco SimpleDraweeView。是否有可能将其作为 Uri 资源?
【问题讨论】: