"Wheat Academy" Android Development tutorial custom ListView Background

Source: Internet
Author: User

Android Custom ListView Background
Android ListView is a very common control in Android development, when doing UI design, many people want to be able to change its background to achieve better visual effect, change its background is actually very simple, we just have to prepare a picture and then specify the properties of Android: background= "@drawable/bg", but don't be happy too early, when you do this, you find that the background is changed, but when you drag or click on the list blank position, the ListItem becomes black, as shown in:


What is this for?
This to start with the ListView effect, the default ListItem background is transparent, and the ListView background is fixed, so in the process of scrolling through the scroll bar if the current display of each item is mixed with the background, So the Android system in order to optimize the process, using a property called Android:cachecolorhint , under the black theme of the default color value is #191919, so there is just the picture, half is black.

What about that?
If you just change the color of the background, you can directly specify android:cachecolorhint as the color you want, if you are using a picture to do the background, it will be as long as the android:cachecolorhint Specified as transparent (#00000000) is possible, of course, in order to beautify is to sacrifice a little efficiency. The final beautification effect


"Wheat Academy" Android Development tutorial custom ListView Background

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.