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.
source share