How to set transparency of a background image Android xml file

后端 未结 9 713
南笙
南笙 2020-12-08 02:24

I have put an image in as the background of my android application with the following line of code:

 android:background=\"@drawable/background\"
9条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-08 03:03

    You can set the alpha property:

    android:alpha="0.4"
    

    via code :

    yourView.setAlpha(0.5f);
    

    only the background :

    yourView.getBackground().setAlpha(120);  // here the value is an integer not float
    

提交回复
热议问题