android switch控件

<Switch
        android:layout_width="wrap_content"
        android:layout_height="@dimen/minCellHeight"
        android:checked="true"
        android:button="@null"
        android:thumb="@null"
        android:background="@drawable/switch_btn"/>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item
            android:drawable="@mipmap/enable"
             android:state_checked="true"/>
    <item
             android:drawable="@mipmap/noenable"
             android:state_checked="false"/>
    <item
           android:drawable="@mipmap/enable"/>
</selector>

 

效果图就是图片的效果,以上图片可以直接拿来用

android:thumb="@null"这句功能只要是屏蔽android自带的效果图片
原文地址:https://www.cnblogs.com/hualuoshuijia/p/9441005.html