简体   繁体   中英

Android ListView Selection When Image is Background

I have set an Android List which has image for background. Looks great, but when I select an item in the ItemList it covers up the picture in back with a default color. I would like to do something more consistent with the background to highlight the selection, like perhaps leave it transparent, but highlight border of the list item row? How could I do this or something else that fits better with an image.

Also I notice dragging down on the list turned several of them black all at once. What can be done about this.

You can set your listView's CacheColorHint to transparent, zero, to make sure it doesn't use the opaque coloring for blending. It will be much slower probably though.

If you want to fix the highlight issues when it selects an index, checkout making a Selector with a state list drawable, http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList . Just define a shape as a stroke drawable rectangle that is x pixels wide and your highlight color of choice. Then set that to listSelector and all should be good.

Check the following link where i wrote a code for changing background effect .

Change ListView background - strange behaviour

You can also use state list diagram as a background to one cell layout. Google it . its like setting a xml as a background which tells which image to choose for normal, pressed, focussed state.

Hope it helps :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM