Unable to change thumb text format of SwitchCompat widget

It's hard for me to change the text size of the compact thumb of the switch.

Here is my layout:

<android.support.v7.widget.SwitchCompat android:id="@+id/switch_compat2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="20dp" android:checked="true" android:switchTextAppearance="@style/MyStyle" android:text="SwitchCompat (SDK v7+)" app:showText="true" /> 

and style:

 <style name="MyStyle"> <item name="android:textColor">#229922</item> <item name="android:textSize">10sp</item> </style> 

still, no matter what I do on "MyStyle", the switch always looks like this:

enter image description here

Ideally, I want it to look like this:

enter image description here

Would anyone be willing to share their drawings to try and match the image above?

I am considering these topics, but not correctly. It makes him look worse.

How to resize a switch widget

Thank you!

+5
source share
1 answer

In fact you need to use

 app:switchTextAppearance="@style/MyStyle" 

Result:

enter image description here

+9
source

Source: https://habr.com/ru/post/1246262/


All Articles