Ich habe dieses seltsame Verhalten auf Android mit AppCompat konfrontiert.Die Farbe von TextView kann nicht mit appcompat auf Android geändert werden
Mein Thema ist die folgende:
<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/white</item>
<item name="colorPrimaryDark">@color/gray_dark</item>
<item name="colorAccent">@color/green</item>
<item name="actionMenuTextColor">@color/gray_dark</item>
</style>
<style name="MyTheme.GreenButton" parent="Widget.AppCompat.Button">
<item name="android:background">@drawable/green_button</item>
<item name="android:textColor">@color/white</item>
<item name="android:textSize">18sp</item>
</style>
In meinem Layout habe ich auf diese Schaltfläche:
<Button
android:id="@+id/login_button_login"
style="@style/MyTheme.GreenButton"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="Log in"/>
Kompilieren auf Android 6 funktioniert perfekt. Unter Android 5 ist die Textfarbe der Schaltfläche jedoch schwarz und kann nicht mit xml textColor geändert werden. Es funktioniert jedoch mit setTextColor direkt im Code.
Was fehlt mir? Warum sollte das appcompat-Thema je nach SDK-Version anders sein? Dieses Problem betrifft auch meine Textansichten, die alle grau sind.