I want to change my toggle view enabled and disable state appearance. Can someone tell me how to do the same?
First create a selector in drawable folder of your project
which will look like this:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_checked="false" android:drawable="@drawable/toggle_off" />
<item android:state_checked="true" android:drawable="@drawable/toggle_on" />
</selector>
Don't forget to keep toggle_off.png, and toggle_on.png in your drawable folder.
and then apply this selector in your toggle button as follows:
<ToggleButton
android:id="@+id/togglerToggle"
android:background="@drawable/toggle_indication_selecter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
toggle_indication_selecter is selector name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With