CookieMonster CookieMonster - 1 year ago 65
Android Question

How do I get the linearlayout to take up the whole space of the scrollview?

I have a scrollview

that takes up my whole screen that will hold a linearlayout
that will also take up the whole screen that will hold various numbers of textviews. I want the textviews to show up starting from the bottom of the screen and then become scrollable when they fill up to the top. My problem is that when I add background colors to see where layouts are, the linearlayout
appears to wrap contents at the top of the screen and does not fill the whole screen. This causes the textviews to fill from top down instead of bottom up.

This is my relevant code:

ScrollView sView = (ScrollView) findViewById(

LinearLayout newLL = new LinearLayout(this);

ScrollView.LayoutParams sparams = new ScrollView.LayoutParams(

Note: When I add in the textviews, I set their gravity to bottom but since the linearlayout wraps and is at the top, it doesn't do anything. I suspect something wrong with my

Answer Source

You need to set android:fillViewport property to your ScrollView. You can either do that in layout xml by putting:


within the scrollview description. Or,

ScrollView sView = (ScrollView) findViewById(
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download