ListView contents get cutoff after Adapter update

前端 未结 3 1728
半阙折子戏
半阙折子戏 2021-01-25 01:02

I have a number of vertically stacked panels in my UI. Each panel contains a ListView. Based on user interaction, the number of items in the ListView gets updated.

My pr

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-25 01:50

    (You can add a ListView inside a ScrollView but not without a little work (as they are both Scrollable components - how would the OS know which one you're trying to scroll?). You would need to add isScrollContainer="false" on your ListView.)

    
    

    The entire point of a ListView is it has a set height as dictated by the layout of your page. It only becomes scrollable when it's children's combined height exceed the area required to display it.

    It sounds like what you actually want is something more akin to a LinearLayout which is backed by an Adapter, there are several implementations out there on the web or you can create your own.

    However, you can hack a ListView into this behaviour by dynamically resizing your ListView programatically by setting it's Height to: listCount * itemHeight. This would have the effect of consistently expanding your ListView.

    You will likely find that as you develop your UI design you will no longer require such a component.

提交回复
热议问题