-1

How to define Spinner style to achieve selection result like in the Material Guidelines?

I'm using Widget.AppCompat.Spinner but selected item text have the same color like other items not accent.

not_again_stackoverflow
  • 1,285
  • 1
  • 13
  • 27
Dawid Hyży
  • 3,581
  • 5
  • 26
  • 41

1 Answers1

-1

Suppose this is the Spinner you're using,

<Spinner
      android:id="@+id/spinner1"
      android:layout_width="wrap_content"
      android:layout_height="@dimen/spinner_height"
      android:background="@drawable/spinner_bg"
      android:divider="@drawable/list_divider"
      android:drawSelectorOnTop="true"
      android:popupBackground="@color/spinner_popup"/>  

make ur spinner_bg.xml look like this...

<item android:drawable="@drawable/whatever" android:state_focused="true" android:state_pressed="false"/>
<item android:drawable="@drawable/whatever" android:state_focused="true" android:state_pressed="true"/>
<item android:drawable="@drawable/whatever" android:state_focused="false" android:state_pressed="true"/>
<item android:drawable="@drawable/whatever" android:state_selected="true"/>

<item android:state_activated="true" android:drawable="@color/selected_spinner_item"/>

<item android:drawable="@drawable/normalwhatever"/>
not_again_stackoverflow
  • 1,285
  • 1
  • 13
  • 27