Reputation: 2327
I already read many ways to change spinner textColor in an ActionBar, but I really can't figure it out what is missing to make what I need.
This is how I have my actionbar spinner:
As you can see, I have white text on spinner items. I need to change it to black.
My res/styles file is this one.
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
<item name="android:dropDownListViewStyle">@style/MyDropDownListView</item>
<item name="android:dropDownItemStyle">@style/MyDropDownItemView</item>
<!-- <item name="android:textColor">@color/white</item> -->
</style>
<!-- ActionBar styles -->
<style name="MyDropDownListView" parent="@style/Widget.AppCompat.ListView.DropDown">
<item name="android:background">@color/white</item>
</style>
</resources>
I changed background to white, but now i need to change text to black and I can't do it.
Some one can help me?
Upvotes: 4
Views: 3129
Reputation: 3338
I think the easiest way is to create a custom spinner item layout for your spinner, but with only a textview & it's color set to whatever you want it to be.
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:textSize="14sp"
android:textColor="#000000" />
Here is also a post that explains how to do it by changing the xml styles: Android Actionbar navigation spinner text color
UPDATE:
Remove the "android:" part from the xml statments that change something from the appcompat library. In my app it did the trick. So instead of this:
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
<item name="android:dropDownListViewStyle">@style/MyDropDownListView</item>
<item name="android:dropDownItemStyle">@style/MyDropDownItemView</item>
<!-- <item name="android:textColor">@color/white</item> -->
</style>
You remove the "android:" part:
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
<item name="dropDownListViewStyle">@style/MyDropDownListView</item>
<item name="dropDownItemStyle">@style/MyDropDownItemView</item>
<!-- <item name="textColor">@color/white</item> -->
</style>
UPDATE 2:
So i'll just post how i style my appcompat apps, so maybe you can see what i don't see. I have 2 folders: resources/values & resources/values-v14.
In the resource/value my style.xml file looks like this:
<style name="Theme.Jamesstyle" parent="@style/Theme.AppCompat.Light">
<item name="actionBarStyle">@style/Actionbar.FlatUi</item>
<item name="actionBarTabStyle">@style/ActionBar.FlatUi.Tabs</item>
<item name="actionBarTabTextStyle">@style/ActionBar.FlatUi.Text</item>
<item name="homeAsUpIndicator">@android:color/transparent</item>
</style>
<style name="Actionbar.FlatUi" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">@color/bizzumi_light</item>
<item name="backgroundStacked">@color/bizzumi_red</item>
<item name="backgroundSplit">@color/bizzumi_red</item>
<item name="titleTextStyle">@style/TitleColor</item>
<item name="displayOptions">showHome|homeAsUp|showTitle</item>
</style>
<style name="TitleColor" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="textColor">#000099</item>
</style>
And in my resources/values-v14 style.xml file i have:
<style name="Theme.Jamesstyle" parent="@style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">@style/Actionbar.FlatUi</item>
<item name="android:actionBarTabStyle">@style/ActionBar.FlatUi.Tabs</item>
<item name="android:homeAsUpIndicator">@android:color/transparent</item>
<item name="android:actionBarTabTextStyle">@style/ActionBar.FlatUi.Text</item>
</style>
<style name="Actionbar.FlatUi" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">@color/bizzumi_light</item>
<item name="android:backgroundStacked">@color/bizzumi_light</item>
<item name="android:backgroundSplit">@color/bizzumi_light</item>
<item name="android:titleTextStyle">@style/TitleColor</item>i
<item name="android:displayOptions">showHome|homeAsUp|showTitle</item><item name="displayOptions">showHome|homeAsUp|showTitle</item></style>
<style name="TitleColor" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#000099</item>
</style>
Maybe try this folder structure and create 2 different styles.xml files. Otherwise i'm clueless. Good luck!
Upvotes: 2
Reputation: 252
`<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
<item name="android:dropDownListViewStyle">@style/MyDropDownListView</item>
<item name="android:dropDownItemStyle">@style/MyDropDownItemView</item>
<!-- <item name="android:textColor">@color/white</item> -->
</style>
<!-- ActionBar styles -->
<style name="MyDropDownListView" parent="@style/Widget.AppCompat.ListView.DropDown">
<item name="android:background">@color/white</item>
<item name="android:textColor">#000000</item>
</style>
Upvotes: 0