android listview item style?

android, listview, styles

Solution

Sure, it's best to use styles here:

<!-- res/values/styles.xml -->
<style name="ListView" parent="@android:style/Widget.ListView">
    <item name="android:background">@color/light_grey</item>
    <item name="android:cacheColorHint">@android:color/transparent</item>
    <item name="android:divider">@android:color/transparent</item>
    <item name="android:dividerHeight">0dp</item>
    <item name="android:listSelector">@drawable/list_item_selector</item>
</style>

The `@color/light_grey` definition:

<!--- res/values/colors.xml --->
<?xml version="1.0" encoding="utf-8"?>
<resources>
   <color name="light_grey">#cccccc</color>
</resources>

You'll have to define the `light_grey` color in your `colors.xml` and create the card style `list_item_selector.xml` in your drawables folder:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">    
    <item android:drawable="@drawable/item_selected" android:state_pressed="true"/>
    <item android:drawable="@drawable/item_focused" android:state_focused="true"/>
    <item android:drawable="@drawable/item_normal"/> 
</selector> 

Problem

before i posted this thread , I've googled ( how to style listview items ) i cannot find a good example to showing how to style listview item ( normal , touch , long click etc ) background colors also i want to do like this VK listview with border radius and box shadow , please i really need this help also other people searching for this is there any example or can some one tell me what i have to put inside the xml selector background of the item ? image one show how to listview item has border radius and shadow image 2 showing when i click on the item so guys is there any way to do like this ?

Original source