Non stretching ScrollView
I have a scroll view inside a liner layout, here is my layout file
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<!-- Other widgets go here -->
<Scroll开发者_开发百科View
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<!-- Scroll view content -->
</ScrollView>
</LinearLayout>
I want ScrolView's height was dependent to its content - wrap it, however if this height makes the whole layout height more that screen size it should be fixed to fit screen's height. How can achive it?
If you want the scrollview to fill the entire screen even if the data isn't enough to do so then try this instead
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- Other widgets go here -->
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<!-- Scroll view content -->
</ScrollView>
</LinearLayout>
add this as attribute to the scrollview
android:fillViewport="true"
精彩评论