如何定义微调器样式以实现选择结果,如Material Guidelines?
我正在使用Widget.AppCompat.Spinner
,但所选的项目文字与其他不重音的项目具有相同的颜色。
答案 0 :(得分:-1)
假设这是您正在使用的Spinner
,
<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"/>
让你spinner_bg.xml
看起来像这样......
<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"/>