Opacity on a background Drawable image in View (using XML Layout)

后端 未结 5 499
借酒劲吻你
借酒劲吻你 2021-01-01 10:57

I was just wondering if there was a way to change the opacity of the background image for a View (ie. TextView, etc.).

I know that I can se

5条回答
  •  有刺的猬
    2021-01-01 11:39

    This might make your Work simpler

    View backgroundimage = findViewById(R.id.background);
    Drawable background = backgroundimage.getBackground();
    background.setAlpha(80);
    

    Alpha Values 0-255, 0 means fully transparent, and 255 means fully opaque

    from: This Answer

提交回复
热议问题