开发者

Non stretching ScrollView

开发者 https://www.devze.com 2023-02-14 18:28 出处:网络
I have a scroll view inside a liner layout, here is my layout file <LinearLayout android:orientation=\"vertical\"

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"
0

精彩评论

暂无评论...
验证码 换一张
取 消