设置ImageView透明:
ImageView.setBackgroundDrawable(drawable);
ImageView.getBackground().setAlpha(100);
设置ImageView不透明:
ImageView.setBackgroundDrawable(drawable);
ImageView.getBackground().setAlpha(255);
如果有其他控件引用了这个drawable图片, 则透明时,其他控件也会透明. 应用mutate();
ImageView.setBackgroundDrawable(drawable.mutate());
ImageView.getBackground().setAlpha(100);
本文介绍如何使用setBackgroundDrawable和setAlpha方法来调整ImageView的透明度,并提供了使修改仅影响目标ImageView而不影响其他引用相同Drawable组件的方法。
561

被折叠的 条评论
为什么被折叠?



