美文网首页
Android Switch 修改文字颜色

Android Switch 修改文字颜色

作者: Lost_Robot | 来源:发表于2019-12-13 16:42 被阅读0次
通常的Switch默认按钮

此时默认的文字颜色是黑色的。

想要修改文字的颜色:
1.在Style文件中添加style:

 <style name="switch_text_color_white" parent="@android:style/TextAppearance.Small">
        <item name="android:textColor">@color/colorWhite</item>
    </style>

2.使用

  android:switchTextAppearance="@style/switch_text_color_white"
设置背景和文字的颜色
  <Switch
        android:layout_width="70dp"
        android:layout_height="25dp"
        android:background="@drawable/bg_a"
        android:drawableEnd="@drawable/down_icon"
        android:drawablePadding="5dp"
        android:gravity="end|center"
        android:paddingStart="0dp"
        android:paddingEnd="10dp"
        android:showText="true"
        android:switchTextAppearance="@style/switch_text_color_white"
        android:text="@string/account_str"
        android:thumb="null"
         />

相关文章

网友评论

      本文标题:Android Switch 修改文字颜色

      本文链接:https://www.haomeiwen.com/subject/drnfnctx.html