Reputation: 344
the many other answers do tell me that android:textColor is the one that does the trick. However no matter what attribute I change in my styles, the app still shows default Black text.
In fact, I cannot even see an attribute called textColor or the likes of it in the layout editor - attribs tab.
Upvotes: 1
Views: 376
Reputation: 24
I hope my solution would work,
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textColor="#ff0000" />
And then change your declaration of the spinner to use the R.layout.spinner_item:
ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.planets_array, R.layout.spinner_item);
spinner.setAdapter(adapter);
Upvotes: 0
Reputation: 3268
See here: Spinner with custom text font and color
Here you can make a custom xml file in layout folder where you can add this:
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#333333"
android:padding="10dp"
android:textStyle="bold" />
And then in your code mention it like this:
val adapter = ArrayAdapter.createFromResource(this, R.array.array_name, R.layout.custom_spinner) // where array_name consists of the items to show in Spinner
adapter.setDropDownViewResource(R.layout.custom_spinner) // where custom-spinner is
mycustom xml file.
And then set the adapter.
Upvotes: 1