Style settings in android listview properties
Style settings in android listview properties.
In Android, ListView and its properties (headerDividersEnabled, choiceMode, footerDividersEnabled, dividerHeight, divider, entries etc) is the most commonly used control, UI design done, many people want to be able to change its background, so that he can meet the overall UI design, change the background back is very simple just need to prepare a picture and then Once you do this, you’ll see that the background is changed. “Style settings in android listview properties.” But when you drag, or when you click on a list of empty positions, you see that the ListItem is turned into a listener. Black, and destroyed the overall effect.
This Listview effect from the start, the default ListItem background is transparent, and ListView background is fixed, so scroll in the rolling process if the real time to go to the current display of each Item with the background Mixed operation, android system in order to optimize the use of this process, it uses a property called android: cacheColorHint in the black theme default color value is # 191919, so there just the picture, half of the black.
headerDividersEnabled
If you just change the color of the background, you can directly specify the android: cacheColorHint you want the color, if you are using pictures to do the background, then it will be as long as the android: cacheColorHint designated as transparent (# 00000000) can, of course, Beautification is to sacrifice some efficiency. Finally, do not return to the above mentioned results you do not want to!
-Style settings in android listview properties.
Customize the split line between the ListView lines
In the Android platform, the system control provides a flexible customization options, all based on ListView or AbsListView implementation of the widget control can be set through the following method of dividing line spacing line, the dividing line can customize the color, or picture. In the ListView, we use the attribute android: divider = “# FF0000” to define the delimiter as red. Of course, the value here can point to a drawable picture object, if the use of the picture may be higher than the system default pixel, you can set the height of 6 pixels Android: dividerHeight = “6px”, of course, in the Java ListView also have related methods can be set. |
headerDividersEnabled
-Style settings in android listview properties.
1) Click on Item without background color change
Add the following properties to the ListView control in the xml file:
Android: listSelector = “@ drawable / timer_list_selector”
Define the attribute value for timer_list_selector in the drawable
The timer_list_selector.xml is defined as follows:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true"android:drawable="<a href="http://my.oschina.net/asia" target="_blank">@android</a> :color/transparent" />
</selector>
In the values folder colors.xml defined transparent as follows:
<color name="transparent">#50000000</color>
2) There is no gap between items
In the xml file ListView control by adding the following attributes:
android:divider="#00000000"
Or in javaCode as follows:
ListView.setDividerHeight (0);
3) Calling the notifyDataSetChanged () method in a custom BaseAdapter will call the baseView’s getView () method again.
Intentions of friends should be able to find, set the background in the listview after. There will be some problems.
-Style settings in android listview properties.
1., listview in the drag when the background image disappears into a black background. Wait until the drag to complete our own background picture is displayed.
2, the top and bottom of the listview has a black shadow.
3, lsitview between each item need to set a picture as the interval.
For the above problem in the listview of the xml file to set the following statement.
Problem 1 has the following code knot solved android: scrollingCache = “false”
Problem 2 is solved with the following code: android: fadingEdge = “none”
Problem 3 is solved with the following code: android: divider = “@ drawable / list_driver” where @ drawable / list_driver is an image resource
Overall as follows.
<ListView
android:id="@+id/myListView01"
android:layout_width="fill_parent"
android:layout_height="287dip"
android:fadingEdge="none"
android:divider="@drawable/list_driver"
android:scrollingCache="false"
android:background="@drawable/list">
</ListView>
-Style settings in android listview properties
How useful was this post?
Click on a star to rate it!
Average rating / 5. Vote count:
We are sorry that this post was not useful for you!
Let us improve this post!
Thanks for your feedback!
Leave a Reply