【发布时间】:2015-10-28 12:24:32
【问题描述】:
我正在尝试使用两个图像分别表示 false 和 true 来实现自定义开关。但问题是我们的默认开关图像与自定义开关图像重叠。
下面是我的 Switch 代码:
<Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Do you want the current offer as your final offer"
android:background="@null"
android:button="@null"
android:textOff=""
android:textOn=""
android:drawableRight="@drawable/switch"
android:textSize="16sp"
android:textColor="#9B9B9B"
android:id="@+id/switch1"
/>
以下是我的switch.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/dummy_toggle_off"
android:state_checked="false" />
<item
android:drawable="@drawable/dummy_toggle_on"
android:state_checked="true" />
<item
android:drawable="@drawable/dummy_toggle_off"/>
</selector>
这是生成的图像:
【问题讨论】: