In Android, the overall background turns black when listview sets the background image and is dragged.

Source: Internet
Author: User

In Android, listview is a commonly used control. When we use it, we often encounter the phenomenon that the entire view is dimmed after clicking, which is particularly evident after setting the background image.
Starting from the effect of listview, the default listitem background is transparent, while the background of listview is fixed, therefore, if the display content of each item is mixed with the background in real time during the scroll bar process, the android system uses Android: cachecolorhint to optimize this process.
In the black topic, the default color value is #191919, so the entire view is dimmed.
To solve this problem, you only need a line of code. 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 specify Android: cachecolorhint as transparent (#00000000.
Method 1: Add the following attributes to the layout file: Android: cachecolorhint = "#00000000 ″.
Method 2: In the Java file, for listactivity, use this in oncreate. getlistview () first obtains the listview, and then calls the listview method: setcachecolorhint (color. transparent), set the background to transparent.

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.