在 ListView 的頂部自定義的 ListView selector。 但是我想讓 listview 中的文本變成白色,如何實現?
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:state_focused="true"
android:drawable="@drawable/stocks_gradient" />
<item android:state_pressed="true"
android:drawable="@drawable/swipeview_selected_gradient" />
<item android:state_focused="true"
android:drawable="@drawable/swipeview_selected_gradient" />
</selector>
對每一個list item,需要用特殊的顏色或 selector。
layout/dash_item.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/DashboardListItem">
... Your text components etc ....
color/dashboard_selector.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:state_focused="true"
android:drawable="@android:color/transparent" />
<item android:state_pressed="true"
android:drawable="@color/dash_border_color" />
<item android:state_focused="true"
android:drawable="@color/dash_border_color" />
</selector>
values/style.xml
<style name="DashboardListItem">
<item name="android:background">@color/dashboard_selector</item>
</style>