How to resize Android ScrollView

I have a layout like this (abstracted):

Scrollview - fill_parent

LinearLayout - wrap_content

ImageView 1 - wrap_content

ImageView 2 -...

ImageView 3

...

During user interaction, some images are replaced with larger or smaller ones, reducing or increasing the area that needs to be scrolled. And that is the problem. Scrollview (SV) does not know about the change, so either it scrolls over a large amount of empty space at the bottom, or cuts off the picture or from the bottom to the bottom.

Question 1: Can I somehow convert the SV to a modified LiearLayout (LL) value?

Question 2: I can get the current size via getHight on LL. But delivering it to SV through a modified LayoutParams does not work - of course, this would only change the height of the SV on the screen. Is there a way to put the altered LL height in SV in code, somehow?

Question 3: I have not tried it yet. Will the creation of SV, LL and its children in the code, and then adding / removing children of the resized element as necessary, so that the SV adapts to the changes?

And the last question: is there a better audit except using ListViews?

+4
source share
1 answer

Have you tried calling requestLayout () when changing images?

+2
source

All Articles