setting transparency to buttons in android

前端 未结 12 1093
悲&欢浪女
悲&欢浪女 2021-02-03 23:28

I want to make Buttons with different transparency levels in android.I have used \"@android:color/transparent\". But it makes the button 100% transparent. I need a

12条回答
  •  无人及你
    2021-02-04 00:12

    Using XML

    If you want to set color and along with that if you want to set transparent then you have to use that color code .

    android:color="#66FF0000"    // Partially transparent red
    android:alpha="0.25"         // 25% transparent 
    

    Using java

    And if you want to set dynamically (java code)then try this,

    myButton.getBackground().setAlpha(64);  // 25% transparent
    

    - i.e .INT ranges from 0 (fully transparent) to 255 (fully opaque)

提交回复
热议问题