-4

I'm able to change text color and size of popup list shown after clicking the spinner. after selecting an item , the item sets on spinner , i've to change this item text size on spinner. please help...

Brijesh Kumar
  • 1,685
  • 2
  • 17
  • 28
  • Possible duplicate of [How to change spinner text size and text color?](http://stackoverflow.com/questions/9476665/how-to-change-spinner-text-size-and-text-color) – Amit Vaghela Jul 08 '16 at 04:46
  • @Amit Vaghela, i dont ve to customize text in the popup window. the solution discuss about popup window text customization. – Brijesh Kumar Jul 09 '16 at 10:26

1 Answers1

0

Use the below adapter constructor for customizing spinner in the way you required.

spinnerAdapter = new ArrayAdapter(this, R.layout.row_spinner 
             /* The resource ID for a layout file containing a layout to use when
              instantiating views. */ ,android.R.id.text1, array);

And you can set the layout resource defining the drop down views using

spinnerAdapter.setDropDownViewResource(R.layout.layout_spinner);

Sample layouts

row_spinner

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@android:id/text1"
    style="?android:attr/spinnerDropDownItemStyle"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:ellipsize="marquee"
    android:gravity="center"
    android:singleLine="true"
    android:textColor="@color/colorBlack"
    android:textColorHint="@color/colorBlack"
    android:textSize="@dimen/text_size_l"/>

layout_spinner

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@android:id/text1"
    style="?android:attr/spinnerDropDownItemStyle"
    android:layout_width="match_parent"
    android:layout_height="@dimen/margin_padding_width_height_6"
    android:ellipsize="end"
    android:gravity="center"
    android:singleLine="true"
    android:textColor="@color/colorBlackLight"
    android:textSize="@dimen/text_size_l"/>
Anoop M Maddasseri
  • 10,213
  • 3
  • 52
  • 73