为您的微调器使用自定义布局,您可以在其中更改文本颜色。这是java示例如何做到这一点:
Spinner mySpinner = (Spinner)findViewById(R.id.spinner);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.row, R.id.weekofday, new String[]{"ELEM 1","ELEM 2"}); // layoout.row is your custom layout.
mySpinner.setAdapter(adapter);
样式微调器:
<?xml version="1.0" encoding="utf-8"?>
并将该drawable设置为您的背景:
<Spinner android:id="@+id/spinner_chemical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
android:background="@drawable/myspinner_background"/>
对于 ListView,您可以设置如下样式:
<style name="ListViewCustomStyle" parent="android:Widget.ListView">
<item name="android:listSelector">@drawable/list_selector_holo_light</item>
<item name="android:fastScrollTrackDrawable">@drawable/fastscroll_thumb_holo</item>
<item name="android:fastScrollThumbDrawable">@drawable/fastscroll_thumb_holo</item>
<item name="android:dividerHeight">0.5dip</item>
<item name="android:divider">#e9e9e9</item>
<item name="android:fadingEdge">none</item>
<item name="android:cacheColorHint">#00000000</item>
</style>
这就是用于设置 listview 样式的可绘制对象:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:drawable="@android:color/transparent" />
<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
<item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/list_selector_disabled_holo_light" />
<item android:state_focused="true" android:state_enabled="false" android:drawable="@drawable/list_selector_disabled_holo_light" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition_holo_light" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition_holo_light" />
<item android:state_focused="true" android:drawable="@drawable/list_focused_holo" />
</selector>
就这样。