简体   繁体   中英

can't change the textsize of the thumb of SwitchCompat widget

I am having a hard time to change the text size of a switch compact thumb.

Here's 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 the style:

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

yet, no matter what I do on "MyStyle", the switch always look like this:

在此输入图像描述

Ideally I want have it look like this:

在此输入图像描述

Anyone would be willing to share their drawables to I can try to match the image above?

I am looking into these threads but not matching properly. It is making it look worse.

How to change the size of a Switch Widget

thank you!

Actually you need to use

app:switchTextAppearance="@style/MyStyle"

Result:

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM