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 ?
A list view is an adapter view that does not know the details, such as type and contents, of the views it contains. Instead list view requests views on demand from a ListAdapter as needed, such as to display new views as the user scrolls up or down. In order to display items in the list, call setAdapter(android.
Android ListView is a ViewGroup that is used to display the list of items in multiple rows and contains an adapter that automatically inserts the items into the list. The main purpose of the adapter is to fetch data from an array or database and insert each item that placed into the list for the desired result.
simple_list_item_1 , (a layout built into Android that provides standard appearance for text in a list), and an ArrayList called restaurants .
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With