How to make button's color like glass's color in android/eclipse

前端 未结 3 1910
别跟我提以往
别跟我提以往 2021-02-06 19:04

Is it possible to make the button\'s background color like glass\'s color, on android/eclipse?..If so how? if not why?

Thanks for your time!...

相关标签:
3条回答
  • 2021-02-06 19:38

    Here is the solution what you are looking for.

    use this xml in drawable

        <?xml version="1.0" encoding="utf-8"?>
     <selector xmlns:android="http://schemas.android.com/apk/res/android">
    
    <item android:state_focused="false">
        <shape >
            <gradient 
                android:startColor="#2F000000" 
                android:endColor="#2fDEDEDE"  
                android:angle="270" />
            <!-- <stroke 
                android:width="1dp" 
                android:color="#bb00ff00" /> -->
            <corners 
                android:radius="3dp" />
            <padding 
                android:left="10dp" 
                android:top="10dp" android:right="10dp" 
                android:bottom="10dp" />
        </shape>
    </item>
    
    <item android:state_pressed="true" >
    
        <shape>
            <gradient 
                android:startColor="#2F000000" 
                android:endColor="#2fDEDEDE" 
                android:angle="270" />
           <!--  <stroke 
                android:width="1dp" 
                android:color="#bb00ff00" /> -->
            <corners 
                android:radius="3dp" />
            <padding 
                android:left="10dp" 
                android:top="10dp" android:right="10dp" 
                android:bottom="10dp" />
        </shape>
    </item>
    
    <item>
        <shape>
             <gradient
                android:startColor="#2F000000" 
                android:endColor="#2fDEDEDE" 
                android:angle="180" />
                <!-- <gradient
                android:startColor="@color/cream_dark"
                android:endColor="@color/cream"
                android:angle="270"/> -->
    
             <!--  <stroke 
                android:width="1dp" 
                android:color="#ffffffff" />  -->
            <corners
                android:bottomRightRadius="3dp"
                android:bottomLeftRadius="3dp"
                android:topLeftRadius="3dp"
                android:topRightRadius="3dp"/>
            <padding 
                android:left="10dp" 
                android:top="10dp" android:right="10dp" 
                android:bottom="10dp" />
        </shape>
    </item>
    
    </selector>
    

    usage

      <Button android:id="@+id/text1"       
            android:layout_marginTop="200dp"
            android:layout_width="fill_parent"
            android:gravity="center"
            android:textColor="#FF1414"
            android:background="@drawable/btn_darkblue"=========>this is the button background
            android:text="Ram kiran"
            android:layout_marginLeft="50dp"
            android:layout_marginRight="50dp"
            android:textSize="15dp"
            android:layout_height="60dp"        
            /> 
    

    It will looks like

    enter image description here

    0 讨论(0)
  • 2021-02-06 19:49

    I'm agree with Cata,but also you can use shapes or use semi transparent colors if these help you.You can see some primary details in about shapes in vogella.com or betaful.com

    0 讨论(0)
  • 2021-02-06 19:56

    Try to do this setting transparent background to button as

    android:background="@android:color/transparent"

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