Home » » Selector on Button Example

Selector on Button Example

Written By MR HARI on Kamis, 04 Juli 2013 | 22.40


Android – Selector on Button Example

Source button.xml

<?xmlversion="1.0"encoding="utf-8"?>

<selectorxmlns:android="http://schemas.android.com/apk/res/android">

<itemandroid:drawable="@drawable/button_pressed"
android:state_pressed="true"/>

<itemandroid:drawable="@drawable/button_normal"
android:state_focused="true"/>

<itemandroid:drawable="@drawable/button_normal"/>

</selector>


Source main.xml

<?xmlversion="1.0"encoding="utf-8"?>

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"/>

<Button
android:id="@+id/button1"
android:layout_width="80dp"
android:layout_height="40dp"
android:background="@drawable/button"
android:textColor="#ffffff"
android:text="Button"/>

</LinearLayout>

The output will be

 


Share this article :

0 komentar:

Posting Komentar

 
Support : Your Link | Your Link | Your Link
Copyright © 2013. Android Center - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger