How to use Scroll View In Android

穿精又带淫゛_ 提交于 2019-11-29 18:26:39

I think you need a simple, two-column organization:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <!-- stuff goes here that should appear above the scrolling areas -->

    <ScrollView
        android:id="@+id/left_side_scroller"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1" >

        <!-- contents of left side go here -->
    </ScrollView>

    <ScrollView
        android:id="@+id/right_side_scroller"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1" >

        <!-- contents of right side go here -->
    </ScrollView>

    <!-- stuff goes here that should appear below  the scrolling areas -->
</LinearLayout>

Alternatively (and perhaps better) it looks like you should be using two ListView elements instead of two ScrollView elements. Each ListView would have the same layout parameters as shown above for the ScrollView. Since a ListView manages scrolling internally, you then don't need ScrollView at all.

Also, you probably want the entire layout to fill the screen, with the "filter" and "sort" elements always at the bottom. To achieve this effect,the top-level layout should have android:layout_height="fill_parent" instead of "wrap_content". Also, the scrollable areas should have android:layout_height="0dp" and a non-zero weight (which they already do).

if you are display your scrollview in Horizontal Linear Layout and given a weight to scrollview then set width of Scrollview to "0dp"

android:layout_width="0dp"

and if it is vertical then

android:layout_height="0dp"

also set your main LinearLayout height to fill parent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!