Important attributes of android ListView

Source: Internet
Author: User

The first is the stackFromBottom attribute. After this attribute is set, the list you prepared will display the bottom of your list, with values true and false.

Android: stackFromBottom = "true"



The second is the transciptMode attribute. You need to use ListView or other controls that display a large number of Items to track or view information in real time, and you want the latest entries to automatically scroll to the visible range. By setting the transcriptMode attribute, You can automatically slide the Android platform control (ScrollBar supported) to the bottom.
Android: transcriptMode = "alwaysScroll"

 

 

The third cacheColorHint attribute, many people want to change its background so that it can adapt to the overall uidesign. To change the background, it is easy to prepare an image and specify the attribute android: background = "@ drawable/bg", but don't be too happy. When you do this, you will find that the background has changed, but when you drag, you can also click the blank position in the list to find that all listitems are black, damaging the overall effect.

If you only change the background color, you can directly specify the android: cacheColorHint as the color you want. If you use an image as the background, you only need to change the android: cacheColorHint is specified as transparent (#00000000 ).

 


The fourth divider attribute is used to set an image between each item as an interval or remove the split line between items.

Android: divider = "@ drawable/list_driver", where @ drawable/list_driver is an image resource. If you do not want to display the split line, set it to android: divider = "@ drawable/@ null"

 


The fifth fadingEdge attribute has a black shadow on the top and bottom.

Android: fadingEdge = "none" is not shadow after it is set ~

 


The sixth scrollbars attribute is used to hide the listView scroll bar,

Android: scrollbars = "none" and setVerticalScrollBarEnabled (true); have the same effect. They are hidden when they are not active, and hidden when they are active.

 


Seventh, the fadeScrollbars attribute. When android: fadeScrollbars = "true" is used to configure the ListView layout, setting this attribute to true can automatically hide and display the scroll bar.

 


Eighth attribute fastScrollEnabled,

Many developers do not know how to enable the quick scroll slider of the ListView list control. Here, the Android Development Network tells everyone that the secondary scroll slider can be done with only one line of code, if you use XML layout, you only need to add the android: fastScrollEnabled = "true" attribute to the ListView node. For Java code, you can use myListView. setFastScrollEnabled (true); to control enabling. The false parameter is hidden. Another point is that when your scrolling content is small and you do not reach the three screen heights of the current ListView, this quick scroll slider does not appear, and this method is still the basic method of AbsListView, you can use Quick scrolling assistance in ListView, GridView, and other subclasses.

 


Ninth drawselectofftop attribute


When set to true, the selector will be drawn over the selecteditem. Otherwise the selector is drawn behind the selected item. Thedefault value is false.

Android: drawselectid Top = "true" click a record. The color is displayed on the top of the record, and the text on the record is hidden. Therefore, you cannot see the text when you click it.

Android: drawselectid Top = "false" click a record, and the color will be behind the record. The background color is displayed, but the recorded text is visible.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.