开发者

Android: ListView in HorizontalScrollView performance issues

开发者 https://www.devze.com 2023-04-11 21:01 出处:网络
I have a need for both horizontal and vertical scrolling of some data in my app. I\'ve overridden HorizontalScrollView and I\'ve allowed it to take an Adapter to populate its data. It behaves much lik

I have a need for both horizontal and vertical scrolling of some data in my app. I've overridden HorizontalScrollView and I've allowed it to take an Adapter to populate its data. It behaves much like a horizontal ListView would behave, except I'm not doing any view recycling. Each item in my custom HorizontalScrollView is a ListView whose items are also populated with an Adapter. Each item in the ListView is a complex view.

I'm able to scroll horizontally, and vertically just fine except that it's performance is a bit chunky. The getView() method in the adapter for populating the custom HorizontalScrollView is only called when the Adapter is first set on the view. However, I noticed that getView() is constantly being called for the ListViews in the HorizontalScrollView. I'm wond开发者_开发问答ering is this is the performance problem?

This question points out a supposed documentation bug pertaining to using a ListView inside of a HorizontalScrollView, but the same warning is not given in the documentation for the vertically scrolling ScrollView documentation.

Will I have performance issues if I put ScrollViews inside of the HorizontalScrollView?


Giving the ListView a dip value for layout_height did the trick. Not setting a height was causing the ListView to keep measuring, calling getView, etc.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号