icecube
icecube

Reputation: 111

SwitchMaterial doesn't change textStyle after applying style

code:

fragment:

        <com.google.android.material.switchmaterial.SwitchMaterial
            android:id="@+id/changeDateFormatSwitch"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="4dp"
            android:text="@string/timeFormat"
            android:theme="@style/switchText"
            app:layout_constraintEnd_toEndOf="@+id/timePicker"
            app:layout_constraintStart_toStartOf="@+id/timePicker"
            app:layout_constraintTop_toBottomOf="@+id/timePicker"
            app:switchTextAppearance="@style/switchText" />

themes:

(as you can see I tried a lot of things... but none of them has worked... yet?)

  <style name="switchText">
        <item name="android:textColor">@color/gold</item>
        <item name="android:textColorPrimary">@color/gold</item>
        <item name="android:editTextColor">@color/gold</item>
        <item name="colorControlNormal">@color/gold</item>
        <item name="colorControlActivated">@color/gold</item>
    </style>

any ideas what should I change to change:

enter image description here

the text color?

Thanks in advance :)

Upvotes: 0

Views: 348

Answers (1)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 364988

You can use:

<com.google.android.material.switchmaterial.SwitchMaterial
    style="@style/Widget.App.CompoundButton.Switch"
    ../>

with:

<style name="Widget.App.CompoundButton.Switch" parent="@style/Widget.MaterialComponents.CompoundButton.Switch">
    <item name="android:textColor">@color/...</item>
</style>

enter image description here

Upvotes: 1

Related Questions