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

8

我希望能够改变一个紧凑型拇指开关的文本大小,但是我遇到了困难。

以下是我的布局:

<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" />

并且样式:

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

然而,无论我在"MyStyle"上做什么,Switch(开关)始终是这个样子:

enter image description here

理想情况下,我希望它看起来像这样:

enter image description here

有人愿意分享他们的drawables,这样我可以尝试匹配上面的图片吗?

我正在查阅这些线程,但并没有正确匹配。它让它看起来更糟。

如何更改Switch Widget的大小

谢谢!

1个回答

16

实际上你需要使用

app:switchTextAppearance="@style/MyStyle"

结果:

在此输入图片描述


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接