java - Android : How to make a radio button look like a toggle button -
this question has answer here:
- android: how radiogroup togglebuttons? 8 answers
i add radio button in layout.
it unchecked begin with. , when click on , becomes checked. when click on again, not become unchecked again?
radiobutton doesn't go checked-state unchecked-state on clicking. there simple solution this. requirement, rather suggest use togglebutton.
i) add below xml , 2 drawables(checked , unchecked) drawable-folder.
toggle_button.xml
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="true" android:drawable="@drawable/checked" /> <!-- checked --> <item android:state_checked="false" android:drawable="@drawable/unchecked" /> <!-- unchecked --> </selector> ii) replace radiobutton togglebutton.
iii) set background of togglebutton above xml-drawable.
hope helps.
Comments
Post a Comment