スイッチアイテムがオフモードのときに背景色を変更するには 、右にテキストを追加するにはどうすればよいですか?オフモードになっているときにスイッチ項目の背景色を変更するにはどうすればいいですか?
私は多くのことを試しましたが、解決策を見つけることができません。
多分カスタムスイッチがありますか?
ありがとうございました。
スイッチアイテムがオフモードのときに背景色を変更するには 、右にテキストを追加するにはどうすればよいですか?オフモードになっているときにスイッチ項目の背景色を変更するにはどうすればいいですか?
私は多くのことを試しましたが、解決策を見つけることができません。
多分カスタムスイッチがありますか?
ありがとうございました。
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/background_color_checked"
android:state_checked="true" />
<item android:color="@color/background_color_not_checked"/>
</selector>
作成描画可能ファイルはスイッチのswitch_thumb.xml
作成描画可能ファイルはスイッチの背景にswitch_track.xmlスイッチ背景の色を設定します親指
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/thumb_color_checked"
android:state_checked="true" />
<item android:color="@color/thumb_color_not_checked"/>
</selector>
スイッチ
<style name="myCustomStyle" >
<item name="thumbTint">@drawable/switch_thumb</item>
<item name="trackTint">@drawable/switch_track</item>
</style>
のスタイルを作成し、スイッチ
<android.support.v7.widget.SwitchCompat
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/myCustomStyle" />
にそれを適用することができますそれは助けにはならない、私はそれがオフだときに、背景を変更する必要があります –