我在这种模式下使用 Glide 在 ImageView 中设置 png 图像(带透明胶片):
Glide.with(context).load(url)
.crossFade()
.placeholder(R.drawable.no_contest)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into((ImageView)container);
是否可以在不设置ImageView背景颜色的情况下设置图片的背景颜色?
谢谢
最佳答案
LayerDrawable
应该使用:
.into(new SimpleTarget<GlideDrawable>() {
@Override
public void onResourceReady(GlideDrawable resource,
GlideAnimation<? super GlideDrawable> glideAnimation) {
final ShapeDrawable background = new ShapeDrawable();
background.getPaint().setColor("color here");
final Drawable[] layers = {background, resource};
container.setImageDrawable(new LayerDrawable(layers));
}
});
关于android - 设置添加背景颜色以滑动图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35683471/