togglebutton

Android toggle button custom look

不问归期 提交于 2019-11-26 06:38:50
问题 I\'ve been trying to customize the toggle button look but with no success. Here is how I want it to look like: Can someone give me a tutorial? 回答1: create toggle_selector.xml in res/drawable <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/toggle_on" android:state_checked="true"/> <item android:drawable="@drawable/toggle_off" android:state_checked="false"/> </selector> apply the selector to your

Toggle button using two image on different state

时光怂恿深爱的人放手 提交于 2019-11-26 06:16:38
问题 I need to make a toggle button using two image instead of ON/OFF state. At off state i set a background image.But the OFF text can not removed while i use background image. And i can not set another image on ON state by clicking the toggle button :( I am new in android. I hope you guys help me get out of this problem 回答1: Do this: <ToggleButton android:id="@+id/toggle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/check" <!--check.xml--