Text color is grey as shown below, i have not set any default color in sytles.xml. As you can see there is a difference between the spinner text color and the textview color.
color difference between Spinner and textview text
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView color"
android:textAlignment="gravity"
android:textAllCaps="false"
android:textSize="16dp"
android:textStyle="bold"
android:gravity="left|center"
android:layout_marginLeft="20dp"
android:padding="12dp" />
<Spinner
android:layout_width="192dp"
android:layout_height="49dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:entries="@array/spinner_items"
android:padding="10dp"
android:spinnerMode="dropdown"
/>
I ran the ColorStateList oldColors = textView.getTextColors();
i got the below result.
ColorStateList{mThemeAttrs=nullmChangingConfigurations=0mStateSpecs=[[-16842910], []]mColors=[603979776, -1979711488]mDefaultColor=-1979711488}
Is the text color is due to this style, my Styles.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
All i want is regular black for texts. And i don't want to add change anything.
Add color property in your TextView
<TextView
android:color="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView color"
android:textAlignment="gravity"
android:textAllCaps="false"
android:textSize="16dp"
android:textStyle="bold"
android:gravity="left|center"
android:layout_marginLeft="20dp"
android:padding="12dp" />
Looks like that is the default color of text. So i have to force it to use regular black in Styles.xml
<item name="android:textColor">@color/textColorPrimaryLight</item>
The reason i was looking for is i want to implement Dark mode. Below article helped my issue. Basically i have to use 2 styles.xml to implement dark mode.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.