In our app, we're using Theme.MaterialComponents.DayNight.NoActionBar
as the parent of our app's theme to implement a switchable day-night theme. It seems to be working everywhere in our app, except specifically the spinner item. The text of the spinner item is black when in dark theme. It's especially weird because the spinner dropdown items are coloured correctly.
I've tried creating a custom layout for the spinner item:
<?xml version="1.0" encoding="utf-8"?>
<TextView
android:id="@+id/spinner_item_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"/>
But any attempts to apply styling to it using attributes from the theme causes the app to crash (e.g. adding android:textColor="?attr/colorOnPrimary"
causes the app to crash when trying to inflate the spinner).
What I want is for the spinner item's TextView to be correctly coloured based on whichever theme is chosen with setDefaultNightMode()
, just like every other TextView. If I'm missing anything important that I need to include, let me know.