Android的,使用自定义背景时,隐藏的股票切换?自定义、背景、股票、Android

2023-09-06 06:45:20 作者:独手毁天下

我有一个自定义绘制为我拨动开关

I've got a custom drawable for my toggle switch

// toggle_selector.xlm
<?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>

然后我申请到交换机

Which I then apply to the switch

    <Switch
        android:id="@+id/geoLocationsToggle"
        android:background="@drawable/toggle_selector"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:textOff=""
        android:textOn=""
        android:textSize="0dp" />

但原(股票)切换仍然显示上层建筑的自定义背景

But the original (stock) toggle still shows overtop the custom background

我如何得到我的自定义的顶部去掉股票开关的?

How do I get rid of the stock switch on top of my custom one?

先谢谢了。

推荐答案

您应该使用的android:拇指的android:跟踪,而不是的android:背景

You should use android:thumb and android:track, not android:background

和你应该写一个选择为他们每个人。

And you should write a selector for each one of them.

 
精彩推荐