改变一个ImageView的透明度

例子:

  Drawable image;
  image=speedImg.getDrawable();
  image.mutate().setAlpha(180);
  speedImg.setBackgroundDrawable(image);

 

第二种方法:

给View设置 AlphaAnimation

public static AlphaAnimation setAnimation(float alpha){
        AlphaAnimation alphaAnimation = new AlphaAnimation(alpha, alpha);
        alphaAnimation.setDuration(10);
        alphaAnimation.setFillAfter(true);
        return alphaAnimation;
    }

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