highlight the entire focus row in ListView
How could I highlight the entire row ,instead of only the space occupied with characters开发者_StackOverflow, in the listview when the row get focused.
For example below, I want the whole line to be highlighted, instead of just "Hello Stackoverflow".
|hello Stackoverflow. |END
Make sure your item has layout_width
set to fill_parent
and layout_height
to wrap_content
.
in yor list in background property you add @drawable/listItemDrawables
in drawable folder named as listItemDrawables.xml you put this code
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/onFocusImage" /> <!-- pressed -->
<item android:drawable="@drawable/imageWithNoFocus" /> <!-- default -->
</selector>
and add two images in drawable folder onFocusImage.png and imageWithNoFocus
now when you select something from the list you will got a felling like everything is selected
精彩评论