Scrolling ListView with Data

Is it possible to do background stretching across the entire ListView, and not just stay in a fixed position?

I remember that in CSS when creating websites you could make the background anchor snap to the background, to stay there when scrolling, I try to archive the opposite of this, forcing the background to follow the data when scrolling down. Is there such a thing for ListView?

+4
source share
1 answer

Using a ListView to accomplish what you want will not be possible.

The ListView only displays a few lines at a time to save it in the Create / manage / etc view. which can drown the system. As a result, the ListView does not even know the overall height of itself - it does not display the row until this row is visible, and the rows can vary in height. If he does not even know his height, how can he have a background covering him all?

However, your idea of ​​using ScrollView will be possible. However, you would lose in ListView optimization - if you had only a few lines, then that doesn't really matter; but if you are talking about dozens of lines (or more), then your application can seriously play out. Also, you are not getting a ListView structure that is oriented towards simplifying the string-based user interface.

You could create your own subclass of ListView (or a custom ListView) that can calculate its total height (as long as you know that each row has a fixed height), and then draw the background accordingly. This is probably what I would do if I needed to do what you described and you had too many rows to just insert into a ScrollView.

+2
source

Source: https://habr.com/ru/post/1383186/


All Articles