pierrotlefou
pierrotlefou

Reputation: 40761

highlight the entire focus row in ListView

How could I highlight the entire row ,instead of only the space occupied with characters, 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

Upvotes: 1

Views: 1373

Answers (2)

Make sure your item has layout_width set to fill_parent and layout_height to wrap_content.

Upvotes: 2

Lukap
Lukap

Reputation: 31963

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

Upvotes: 2

Related Questions