Black after setting the background image in Android listview

Source: Internet
Author: User
from: http://blog.sina.com.cn/s/blog_629b701e0100wu39.html in Android, listview is the most commonly used control. During uidesign, many people want to change its background so that it can conform to the overall uidesign, it's easy to change the background. You only need to prepare an image and specify the attributes
Android: Background = "@ drawable/BG". But don't be so happy. When you do this, the background is changed, but when you drag or click the blank position in the list, it is found that the listitem is black, which damages the overall effect.

Why?

the default listitem background is transparent, the background of the listview is fixed, so if the display content of each item and the background of the current item are mixed in real time during scroll of the scroll bar, therefore, the android system uses an attribute called Android: cachecolorhint to optimize this process. The default color value for the black topic is #191919, half of them are black


what should I do?

If you only change the background color, you can directly specify Android: cachecolorhint is the color you want. If you use an image as the background, you only need to specify Android: cachecolorhint as transparent (#00000000, of course, we have to sacrifice some efficiency for beautification.
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.