An example of listview changing the font color of the selected line is presented
- 2020-05-10 18:51:01
- OfStack
Target: select item with the font #3197FF, and unselected with the font #FFFFFF
Select line item background image 1 with listvew Settings, use selector, but the color setting here should be set in textview in listview.
Similarly, define the itemcolor.xml file and modify the font color of the selected line:
Select line item background image 1 with listvew Settings, use selector, but the color setting here should be set in textview in listview.
<SPAN style="COLOR: #666666"><?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TableRow >
<TextView
android:id="@+id/name_tv"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="25px"
android:textColor="@drawable/itemcolor">
</TextView>
</TableRow>
</TableLayout></SPAN>
Similarly, define the itemcolor.xml file and modify the font color of the selected line:
<SPAN style="COLOR: #666666"><?xml version="1.0" encoding="utf-8" ?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Font color without focus -->
<item
android:state_selected="false"
android:color="#FFFFFF"/>
<!-- Font color when selected -->
<item
android:state_selected="true"
android:color="#3197FF"/>
<!-- Font color when getting focus and clicking in non-touch mode -->
<item
android:state_focused="true"
android:state_pressed="true"
android:color="#3197FF"/>
</selector></SPAN>