简体   繁体   English

无法更改SwitchCompat小部件的文本大小

[英]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: 然而,无论我在“MyStyle”上做什么,开关总是如下所示:

在此输入图像描述

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? 任何人都愿意分享他们的drawables我可以尝试匹配上面的图像?

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 如何更改Switch Widget的大小

thank you! 谢谢!

Actually you need to use 其实你需要使用

app:switchTextAppearance="@style/MyStyle"

Result: 结果:

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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