Reputation: 94319
Inside a ScrollView I have a LinearLayout. The LinearLayout can be as tall as it wants, but I want its minimum height to be at least as tall as its parent (the ScrollView).
<ScrollView
...>
<LinearLayout
...
android:layout_marginTop="@dimen/some_margin"
android:minHeight="match_parent">
This does not work. It won't accept "match_parent"
for minHeight
. So how do I approach this?
Upvotes: 3
Views: 2077
Reputation: 4570
You could use the ScrollView's android:fillViewport="true"
property in the xml file like this:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--Rest of the children-->
</LinearLayout>
</ScrollView>
Upvotes: 8
Reputation: 874
So you just want to avoid having wasted real estate when the stuff in the LinearLayout doesn't fill up the space allowed by the ScrollView? How about just setting LinearLayout height to:
android:layout_height="match_parent"
You could set the same on the ScrollView so that it fits its own parent as well, but not strictly necessary.
Upvotes: 0