Open top menu





activity_main.xml
...................................................................................................................................................................
xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   
xmlns:tools="http://schemas.android.com/tools"
   
android:id="@+id/activity_main"
   
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"
   
android:orientation="vertical"
   
android:gravity="center|top"
   
tools:context="com.project.example.buttonshapes.MainActivity">

    <
TextView
       
android:layout_width="wrap_content"
       
android:layout_height="wrap_content"
        
android:text="Clickble Button Shpes" />

    <
Button
       
android:text="Button"
       
android:layout_width="fill_parent"
       
android:layout_height="wrap_content"
       
android:id="@+id/button"
       
android:layout_margin="7dp"
       
android:background="@drawable/btn_gradient"/>

    <
Button
       
android:text="Button1"
       
android:layout_width="fill_parent"
       
android:layout_height="wrap_content"
       
android:id="@+id/button1"
       
android:layout_margin="7dp"
       
android:textColor="#ffffff"
       
android:background="@drawable/green_back_button"/>

</
LinearLayout>
 ..................................................................................................................................................................


btn_top_shape.xml
...................................................................................................................................................................

xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <
corners
        
android:topLeftRadius="6dp"
       
android:topRightRadius="6dp"
       
android:bottomRightRadius="6dp"
       
android:bottomLeftRadius="6dp">
    </
corners>
    <
stroke
       
android:width="3dp"
       
android:color="#999999">
    </
stroke>
    <
gradient
       
android:angle="270"
       
android:startColor="#a0a0a0"
       
android:endColor="#ffffff">
    </
gradient>
</
shape>
...................................................................................................................................................................


btn_bottom_shape.xml
...................................................................................................................................................................


xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <
corners
       
android:topLeftRadius="6dp"
       
android:topRightRadius="6dp"
       
android:bottomRightRadius="6dp"
       
android:bottomLeftRadius="6dp">
    </
corners>
    <
stroke
       
android:width="3dp"
       
android:color="#999999">
    </
stroke>
    <
gradient
       
android:angle="270"
       
android:startColor="#ffffff"
       
android:endColor="#a0a0a0">
    </
gradient>
</
shape>
...................................................................................................................................................................


btn_gradient.xml
...................................................................................................................................................................

xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <
item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/btn_top_shape" />
    <
item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/btn_top_shape" />
    <
item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/btn_bottom_shape" />
    <
item android:drawable="@drawable/btn_top_shape" />
</
selector>

 ..................................................................................................................................................................


green_back_button.xml
...................................................................................................................................................................

xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <
corners
       
android:topLeftRadius="4dp"
       
android:topRightRadius="4dp"
       
android:bottomRightRadius="4dp"
       
android:bottomLeftRadius="4dp">
    </
corners>
    <
stroke
       
android:width="6dp"
       
android:color="#008040">
    </
stroke>
    <
gradient
       
android:angle="270"
       
android:startColor="#008080"
       
android:endColor="#008000">
    </
gradient>
</
shape>
 ..................................................................................................................................................................

 green_bottom_select.xml
 ..................................................................................................................................................................


xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"


android:shape="rectangle">
    <
corners
       
android:topLeftRadius="4dp"
       
android:topRightRadius="4dp"
       
android:bottomRightRadius="4dp"
        
android:bottomLeftRadius="4dp">
    </
corners>
    <
stroke
       
android:width="6dp"
       
android:color="#008040">
    </
stroke>
    <
gradient
       
android:angle="270"
       
android:startColor="#008000"
       
android:endColor="#008080">
    </
gradient>
</
shape>
 ..................................................................................................................................................................


green_back_button.xml
 ..................................................................................................................................................................

xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <
item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/green_top_select" />
    <
item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/green_top_select" />
    <
item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/green_bottom_select" />
    <
item android:drawable="@drawable/green_top_select" />
</
selector>
 ..................................................................................................................................................................






0 comments