4
votes

Is there any way to have a ScrollView with android:fillViewport="true" and a child LinearLayout filling all the view when the content of the LinearLayout is not hight enough?

So far, in a LinearLayout inside a ScrollView we have to use android:layout_height="wrap_content". Can we add something else for filling all ScrollView?

2
use match_parent in layout height - suresh

2 Answers

2
votes

What's the point? LinearLayout content won't stretch to fill ScrollView anyway. If you want to center LinearLayout in (fillViewPorted) ScrollView, use android:gravity="center" in LinearLayout. If you want to use LinearLayout weights to fill screen, don't use ScrollView, as it's height is potentially infinite. If

1
votes

Set the android:layout_weight of the contents to 1.0. That will force the contents to use the available empty space when it is shorter than the ScrollView. It only works when android:fillViewport= "true" is set on the scroll view.

Source: http://www.curious-creature.com/2010/08/15/scrollviews-handy-trick/