ListView in ScrollView potential workaround

前端 未结 2 1438
暖寄归人
暖寄归人 2020-12-01 13:45

I\'ve done all of the research on the matter. I know that Google thinks it\'s pointless and that the developers, know that it\'s not. I also know that there is no known work

2条回答
  •  悲哀的现实
    2020-12-01 14:27

    Out of curiosity, is your layout using RelativeLayout? If so, calling measure(0,0) will always throw an NPE, but a LinearLayout will not. http://groups.google.com/group/android-developers/browse_thread/thread/5a947482d7dcb605

    Change it to Linear and you can make that call. I hope that helps!


    I have a situation in my app where I have paragraphs of text, imageviews, all sorts of information on a given subject...and then, depending on the item, there is possibly a ListView of comparison data in the middle of all of that info. About one in every 10 items has it, nestled between all the text. The comparison data is never more than 4 items at max, so I don't want the ListView to scroll, ever. I just want the ListView to appear in its entirety at the exact point I specify.

    Adding them all as nested Linear Layouts is insane, so is using MergeAdapter to put all of that together when I may not even have a ListView on screen. And using complex ListView headers & footers is out of the question as well.

    I'm not the first person to want that kind of functionality, and I won't be the last. The above solution is nearly perfect, it sizes my ListView so that it's full on screen, and all the scrolling comes from the ScrollView parent. (It's easy as sin to do on the iOS SDK, btw., and a lot of apps over there do similar things; we'll need a good solution for this.)

提交回复
热议问题