Recently writtenProgramWhen a sliding listview item is encountered, the listview background is always black and I don't know how to solve it. So Baidu just got it done, and it was owned by the blogger.
B blog:
In Android, listview is the most commonly used control. During the 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 property Android: Background = "@ drawable/BG". But don't be so happy. When you do this, you will find that the background has changed, however, when you drag or click the blank position of the list, it is found that all listitems are black, which damages the overall effect.
Why?
Starting from the effect of listview,
The default listitem background is transparent, while the listview background remains unchanged. Therefore, when the scroll bar is rolled, if you want to display the content and background of each item in real time
The Android system uses an attribute called Android: cachecolorhint to optimize this process. The default color is displayed under the black topic.
The color value is #191919, so the image just appeared, half of which were black.
What should we do?
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 set
Android: cachecolorhint can be specified as transparent (#00000000). Of course, to beautify the image, you must sacrifice some efficiency.