Issue
Question
How can I have the text color change dynamically when the theme changes?
Problem
src="https://i.stack.imgur.com/zUf8Y.png" alt="TextView" />
Text color dynamically changes when the theme is changed
Solution
Solution
Add this style
to your TextView
and the problem should be solved:
style="@style/Theme.Material3.DynamicColors.Light"
Example
<TextView
android:text="@string/testText"
----> style="@style/Theme.Material3.DynamicColors.Light" <-----
android:layout_width="400dp"
android:layout_height="50dp" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" android:id="@+id/textView"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent"/>
Answered By - Mikail B.
Answer Checked By - Senaida (JavaFixing Volunteer)