How to change size of Android ScrollView
Posted
by
user611923
on Stack Overflow
See other posts from Stack Overflow
or by user611923
Published on 2011-02-10T23:22:55Z
Indexed on
2011/02/10
23:25 UTC
Read the original article
Hit count: 274
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 Scrollview (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?
© Stack Overflow or respective owner