android imageView背景透明度的设置

经过项目测试,有两种方法可以使用:

1

ivIcon.getBackground().setAlpha(NOT_ENABLED_ALPHA);

2

AlphaAnimation alpha = new AlphaAnimation(0.3F, 0.3F);
                    alpha.setDuration(0); // Make animation instant
                    alpha.setFillAfter(true); // Tell it to persist after the animation
                    ivIcon.startAnimation(alpha);


个人推荐第二种方法(第一种方法,在同一个acivity中如果有2个或者多个imageView同时使用一张drawable的时候,这几个imageView的透明度会混淆)

你可能感兴趣的:(android开发)