(Android) How to fill ListView background and preserve header transparency

前端 未结 3 1302
不思量自难忘°
不思量自难忘° 2021-02-19 11:18

I have a custom image background that fills the entire screen behind a ListView.

The ListView has a header that contains some data, then a transparent 10dp margin(allowi

3条回答
  •  無奈伤痛
    2021-02-19 11:46

    You need to make the items in the ListView transparent by setting following on the ListView:

    android:background="@android:color/transparent"
    android:cacheColorHint="@android:color/transparent"
    

    Then your items Layout needs to have whatever color/image (this will be put on top of the transparency).

    This should work but will be heavy work on Android as transparency really takes its toll on Android especially when it's in a ListView where there is a lot of UI updates.

提交回复
热议问题