setting transparency to buttons in android

前端 未结 12 1089
悲&欢浪女
悲&欢浪女 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-03 23:48

    Instead of this:

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

    you can use this:

    android:background="#00FFFFFF"

    0 讨论(0)
  • 2021-02-03 23:55

    Setting the android:alpha property for button will help... Set the colour you want and then set the alpha property.

    android:color="#e5e5e5"    
    android:alpha="0.25"
    

    0.25 means 25%

    0 讨论(0)
  • 2021-02-03 23:58

    try adding this to your button android:color="#55000000""

    <Button android:id="@+id/three" android:text="@string/dtmf_3"
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent"
            android:layout_weight="1" 
            android:color="#55000000" <!--Here--!>
            android:textColor="@color/white" ></Button>
    
    0 讨论(0)
  • 2021-02-04 00:00

    You can try setting

    android:alpha="0.7"
    

    property on your Button in xml layout file

    0 讨论(0)
  • 2021-02-04 00:02

    You can define your own "transparent" color in styles.xml and play with the alfa of the color, for example:

    <color name="Transparent">#00000000</color>
    <color name="Transparent80">#80000000</color>
    

    EDIT: second one is 50% transparency

    0 讨论(0)
  • 2021-02-04 00:02

    Try android:background="#70FF0000" in your button code. Works for me.

    0 讨论(0)
提交回复
热议问题