修改switch的样式

来源:互联网 发布:淘宝土特产店铺简介 编辑:程序博客网 时间:2024/06/01 09:21

第一步,创建Switch主题

<style name="Switch" parent="Theme.AppCompat.Light">    <!-- active thumb & track color (30% transparency) -->    <item name="colorControlActivated">#46bdbf</item>    <!-- inactive thumb color -->    <item name="colorSwitchThumbNormal">#f1f1f1    </item>    <!-- inactive track color (30% transparency) -->    <item name="android:colorForeground">#42221f1f    </item></style>

在xml文件中使用这个主题

<Switch    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:theme="@style/Switch"    />