Monday, 22 October 2012

android: toggle and switch buttons


 <ToggleButton
            android:id="@+id/switchitem"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/toggle"
            android:checked="true" 
            android:textOn=""
            android:textOff=""/>

and the drawable will be :
toggle_me_on.png

toggle_me_off.png

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_checked="true"
        android:drawable="@drawable/toggle_me_on" /> <!-- pressed -->
    <item android:drawable="@drawable/toggle_me_off" /> <!-- default/unchecked -->
</selector>

No comments:

Post a Comment