在滚动视图线性布局不占据全高 [英] Linear layout in a scrollview does not occupies full height
问题描述
我有一个线性布局说V1,L1里面我有一个滚动视图V2,里面滚动型我还有一个线性布局V3,V3现在有一个gridtview V4。该PBM是,如果我的ListView有说6个项目中,只有2可见,休息我有,当我看到大量的空置空间,甚至滚动。我设置背景颜色(背景颜色V2:洋红色,对于V3绿),观察到这种:
V2覆盖整个V1
V3涵盖仅一小部分说V2的30%,
V4涵盖完整的V3。
所以我做了几乎所有我可以遵循,使V3覆盖所有V2的,但不能success.I对这个浪费了很多时间,PLZ让我知道这有什么解决办法。
I have a linear layout say V1, inside L1 i have a scrollview V2, Inside scrollview i have another linear layout V3, Now V3 has a gridtview V4. The pbm is that if my listview has say 6 items, only 2 are visible, for rest i have to scroll even when i see plenty of space left vacant. I set the background colors(Background color for V2:magenta, for V3 Green) and observed this: V2 covers the entire V1 V3 covers only a fraction say 30% of V2, V4 covers complete V3. So I have done nearly everything i could follow to make V3 cover All of V2, but not success.I have wasted many hours on this, plz let me know if this has any solution.
//滚动型PARAMS V2
LinearLayout.LayoutParams svParams =新LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT,1.0F);
//Scrollview Params V2 LinearLayout.LayoutParams svParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT,1.0F);
因此,所有这些事情我想不工作:
So all these things I tried do not work:
V3.getLayoutParams().height = V2.getHeight();
//((LinearLayout)gv.getParent()).getLayoutParams().height = LinearLayout.LayoutParams.FILL_PARENT;
//((LinearLayout.LayoutParams)((LinearLayout)gv.getParent()).getLayoutParams()).weight = 1.0F;
//((LinearLayout) ((LinearLayout)gv.getParent()).getParent()).getLayoutParams().height = LinearLayout.LayoutParams.FILL_PARENT;
但是,如果我给一些硬codeD值V4,它确实增加了它的所有父视图的高度,但我不想这样做,这是不可行的在我的应用
BUT if I give some hardcoded value for V4, it does increases the height of all its parent views,but I do not want to do that and that is not feasible in my application
推荐答案
只需使用 setFillViewport(真)
在滚动型
。这样,如果内容的滚动型
比的滚动型
,这将扩大到可见部分小填补该区域。
Just use setFillViewport(true)
on the ScrollView
. This way, if the content of the ScrollView
is smaller than the visible portion of the ScrollView
, it will be expanded to fill that region.
这篇关于在滚动视图线性布局不占据全高的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!