I set a image as Listview background, if I want to scroll it with the item, what can I do?
for example: 1 is the background, if I scroll Listview down, it will change from
1
-----1-----1--------
1 1
-1-------------1----
to
--------1----------
1 1
---1----------1----
1 1
maybe I could extends listview and override dispatchDraw, but if I use listFragment, what can I do ? anybody help me?
The code by AndroidLearner works well, except for one bug, see my comment on AndroidLearner's answer. I wrote a Kotlin version of his code that fixes the bug, and also works with any background that was defined in xml like so:
Here is the code:
For the conversion of the
Drawable
to aBitmap
I used this post.In your Activity's XML file define the listview like this ::
(Define the property in this xml file as per your requirement)
Create one Class named MyCustomListView ::
Hope this will solve your problem :)