Rohith
Rohith

Reputation: 1001

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

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!...

Upvotes: 2

Views: 10413

Answers (3)

AkashG
AkashG

Reputation: 7888

Try to do this setting transparent background to button as

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

Upvotes: 1

Ram kiran Pachigolla
Ram kiran Pachigolla

Reputation: 21191

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

Upvotes: 9

hasanghaforian
hasanghaforian

Reputation: 14022

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

Upvotes: 0

Related Questions