I have a layout like this (abstracted):
Scrollview - fill_parent
LinearLayout - wrap_content
ImageView 1 - wrap_content
ImageView 2 - ...
ImageView 3
...
In the course of user interaction some images are replaced by larger or smaller ones, shortening or lenghtening the area to be scrolled. And that is the problem. The Scrollvi开发者_StackOverflow中文版ew (SV) does not know about the change, so either it scrolls over a lot of empty space at the bottom, or cuts off a picture or two at the bottom.
Question 1: Can I somehow make the SV readapt to the changed hight of the LiearLayout (LL)?
Question 2: I can obtain the current size through getHight on the LL. But supplyong it to the SV via changed LayoutParams does not work - of course, that would only change the height of the SV on the screen. Is there a way to put the changed height of the LL into the SV in the code, somehow?
Question 3: I havn't tried it yet. Would creating the SV, LL and its children in code and then adding/removing children of changed size as required, make the SV adapt to the changes?
And last question: Is there a better aüpproach, except using ListViews?
Have you tried calling requestLayout() when images change?
精彩评论