In this tutorials create glass effective button . The design show the button color take same Layout background color's .The create glass button via single gradient Xml .
Gradient Xml
<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>
</selector>
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="7dp"
android:layout_marginTop="41dp"
android:background="@drawable/glass_effect"
android:text="Register" />
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_below="@+id/button1"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:background="#406add"
android:gravity="center"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="7dp"
android:layout_marginTop="41dp"
android:background="@drawable/glass_effect"
android:text="Register" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_below="@+id/linearLayout1"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:background="#ed3636"
android:gravity="center"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="7dp"
android:layout_marginTop="41dp"
android:background="@drawable/glass_effect"
android:text="Register" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_below="@+id/linearLayout2"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:background="#65e23f"
android:gravity="center"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="7dp"
android:layout_marginTop="41dp"
android:background="@drawable/glass_effect"
android:text="Register" />
</LinearLayout>
</RelativeLayout>
0 comments