The ListView control is often used on the android interface. In the UI design, many people want to beautify the background of the control. Changing the background is actually very simple. In the layout file, add the code android: background = "@ drawable/bg" to the ListView control, and bg is the name of the background image. However, after this is done, the background is changed, but when you drag it, or click the blank position of the list, you will find that the ListItem is black, damaging the overall effect. As shown in:
Why? Because the background of ListItem in ListView is transparent by default, and the background of ListView is fixed, the background should be mixed with the display content of each Item during scrolling, in order to optimize this process, android: cacheColorHint is used, and the default color value is #191919 in the black topic, so the picture just now appears. Half of them are black.
If you only want to change the background color, you just need to specify the android: cacheColorHint as the desired color value.
If you want to use an image as the background, you only need to set the android: cacheColorHint value to transparent, that is, set the value to #00000000. In this way, the beautification will sacrifice some efficiency.
After beautification:
From Peking University-Google Android lab