如何改变Android的滚动型的大小 [英] How to change size of Android ScrollView

查看:119
本文介绍了如何改变Android的滚动型的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样一个布局(抽象):

I have a layout like this (abstracted):

滚动型 - FILL_PARENT

Scrollview - fill_parent

的LinearLayout - WRAP_CONTENT

LinearLayout - wrap_content

ImageView的1 - WRAP_CONTENT

ImageView 1 - wrap_content

2的ImageView - ...

ImageView 2 - ...

3的ImageView

ImageView 3

...

在用户交互的过程中的一些图像是由较大或较小的置换,缩短或lenghtening面积要滚动。
而这就是问题所在。滚动视图(SV)不知道的变化,所以要么在底部滑过了很多空白,或者在底部切断一个或两个图片。

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.

问题1:我可以以某种方式使SV重新适应改变的高程LiearLayout(LL)

Question 1: Can I somehow make the SV readapt to the changed hight of the LiearLayout (LL)?

问题2:我可以通过getHight获得关于LL电流的大小。但是通过改变它的LayoutParams到supplyong的SV不工作 - 当然,这只会改变屏幕上的SV的高度。有没有把改变高度LL成在code中的SV,莫名其妙的方式?

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?

问题3:我没有带尝试过呢。将在code创建SV,LL和它的孩子,然后添加/删除作为需要改变大小的孩子,使SV适应这种变化?

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?

和最后一个问题:是否有更好aüpproach,除了使用列表视图

And last question: Is there a better aüpproach, except using ListViews?

推荐答案

你有没有打过电话requestLayout()时,图像变化?

Have you tried calling requestLayout() when images change?

这篇关于如何改变Android的滚动型的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆