October 2018
Intermediate to advanced
464 pages
15h 17m
English
We will start by creating the state selector, which is a resource file defined with XML code. We will then set up the button to use our new state selector. Here are the steps:
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@android:color/darker_gray" android:state_checked="true"/> <item android:drawable="@android:color/white" android:state_checked="false"/></selector>
<ToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" ...