I'm creating a SpinnerAdapter using the built in resource ID android.R.layout.simple_spinner_dropdown_item
SpinnerAdapter mSpinnerAdapter = ArrayAdapter.createFromResource(this, R.array.action_list, android.R.layout.simple_spinner_dropdown_item);
but the textView which that resource ID creates has textColor Black and I need a different color. What's the best way of changing the color but keeping everything else the same?
When I try and create my own textView layout resource in an xml file, e.g.
<?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="@color/White"
/>
then it doesn't behave in the same way as android.R.layout.simple_spinner_dropdown_item because e.g. the padding is different. So
- Is there a way of creating my own layout resource in an xml file which inherits everything from android.R.layout.simple_spinner_dropdown_item and allows me to override the textColor?
- Or is the complete definition of android.R.layout.simple_spinner_dropdown_item available somewhere?
- Or perhaps there's an even easier way somehow?
This question relates to another question that I've asked today (Can't change the text color with Android Action Bar drop-down navigation). I've realised that one answer to that question (and hence this question) is to create my own ArrayAdapter
class which inherits from ArrayAdapter<T>
so that I can always set the color in code whenever the ArrayAdapter gets used (see my answer to that question). But that seems like a very cumbersome solution :-|.
Changing a text color shouldn't be a hard task!