How to change the text color of Default Spinner in android

3.5k views Asked by At

How to change the text color of default spinner. I need to set color grey but by default it shows Black.

Please help me out. Thanks.

2

There are 2 answers

0
Naveen Tamrakar On

item.xml

<?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:textSize="15sp"
android:textColor="#grey color "         
android:padding="5dip"
/>

mAdapter = new ArrayAdapter<String>(this, R.layout.item.xml, array);
0
Yugesh On

Override the adapter to change spinner text color :-

 your_adpter = new ArrayAdapter<String>(getApplicationContext(),android.R.layout.simple_spinner_dropdown_item, array){

        @Override
        public View getDropDownView(int position, View convertView,ViewGroup parent) {
            // TODO Auto-generated method stub

            View view = super.getView(position, convertView, parent);

             TextView text = (TextView)view.findViewById(android.R.id.text1);
             text.setTextColor(Color.BLACK);  

             return view;

        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub

            View view = super.getView(position, convertView, parent);

             TextView text = (TextView)view.findViewById(android.R.id.text1);
             text.setTextColor(Color.BLACK);  

             return view;

        }
    };