Open top menu


In this Tutorial we will Design best Button UI. Button shows Effcet Whene click on button ,the effect show with the help of button gradient .

res/drawable/button_normal.xml
............................................................................................................................................

<?xml version="1.0" encoding="utf-8"?>
 <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  <item>
    <shape android:shape="rectangle">
      <solid android:color="#8e918c" />
    </shape>
  </item>
    <item android:bottom="5dp" >
 
     <shape android:shape="rectangle">
      <solid android:color="#cacaca" />
    </shape>
   </item>  
 </layer-list>


res/drawable/button_action.xml
............................................................................................................................................

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item
             android:state_pressed="true" >
        <shape>
        <solid
        android:color="#cacaca" />
         
            <corners
               android:radius="4dp"/>
            <padding
                android:left="1dp"
                android:top="1dp"
                android:right="1dp"
                android:bottom="1dp" />
        </shape>
    </item>
    <item android:drawable="@drawable/button_normal" android:state_activated="false">      
    </item>
</selector>


main_activity.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:id="@+id/text"
    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="com.androidbeginner.testcode.MainActivity" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="Androidbeginner"
        android:textSize="20sp" />

    <Button
        android:id="@+id/butn_signUp"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:layout_below="@+id/textView1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="67dp"
        android:background="@drawable/button_action"
        android:text="Registration" />


</RelativeLayout>




0 comments