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

时间:2016-04-01 19:13:33

标签: android android-widget

我很难改变开关紧凑型拇指的文字大小。

这是我的布局:

<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”上做什么,开关总是如下所示:

enter image description here

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

enter image description here

任何人都愿意分享他们的绘图,我可以尝试匹配上面的图片吗?

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

How to change the size of a Switch Widget

谢谢你!

1 个答案:

答案 0 :(得分:12)

实际上你需要使用

app:switchTextAppearance="@style/MyStyle"

结果:

enter image description here

相关问题