material-components / material-components/material-components-android

[SwitchMaterial] Impossible to change textcolor which is black in day theme and white in night theme

Open
#4,388 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request Widget: Switch
Dominant language
Java
Stars
17.4k
Forks
3.2k
PR merge metrics
No merged PRs in 30d

Description

I tried in code with setColor, I tried in xml, I tried in the style. Nothing works.

<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/switchNoiseSpeed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textOff="@string/speed"
android:textOn="@string/noise"
app:layout_constraintBottom_toBottomOf="@+id/circularRangeSliderValue"
app:layout_constraintEnd_toEndOf="@+id/circularRangeSliderValue"
app:layout_constraintStart_toStartOf="@+id/circularRangeSliderValue"
app:layout_constraintTop_toTopOf="@+id/circularRangeSliderValue"
app:layout_constraintVertical_bias="0.77"
app:showText="true"
android:textColor="?attr/colorError"
/>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the SwitchMaterial entry point and reproduce the XML example with showText enabled and android:textColor set to colorError. Trace how the displayed on/off text color is resolved in day and night themes; done means the configured textColor is applied in both modes, with a regression test covering the reported case.

Written by the indexing model from the issue text.

Assessment

Tech stack
android
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.