Line layout in scrollview doesn't take full height

I have a linear layout, they say V1, inside L1 I have scrollview V2, inside scrollview I have another linear layout V3, now V3 has a gridtview V4. Pbm is that if there are 6 elements in my list, only 2 are visible, I have to scroll to rest, even when I see that a lot of free space is left free. I set the background color (background color for V2: magenta, for V3 green) and noticed the following: V2 covers the entire V1 V3 covers only a fraction of, say, 30% of V2, V4 covers the full V3. So I did almost everything I could do to make V3 Cover All V2, but not success. I spent a lot of time on this, plz let me know if this has any solution.

// 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; 

BUT, if I give some solid value for V4, it increases the height of all its parent representations, but I don’t want to do this, and this is not possible in my application

+4
source share
2 answers

Just use setFillViewport(true) in ScrollView . Thus, if the contents of the ScrollView smaller than the visible portion of the ScrollView , it will be expanded to fill this area.

+32
source

Try setting android: layout_weight = "1" to L1

-1
source

Source: https://habr.com/ru/post/1337279/


All Articles