简体   繁体   中英

How to use Listview inside Scrollview?

I have a parent scrollview and a listview Inside it. The parent scrollview's property affects the child listview's scrolling property. I can't scroll the listview Only scrollview's other child views are scrolling. How can I solve this issue.

I used the following xml:

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/newmenu_layout"
    android:layout_marginBottom="120dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="10dp"
    android:overScrollMode="never"
    android:scrollbars="none" >

    <LinearLayout
        android:id="@+id/edit_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <ListView
            android:id="@+id/ImageList"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:scrollbars="none" >
        </ListView>

        <RelativeLayout
            android:id="@+id/videodetail"
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/edt_stroke_bg"
            android:orientation="horizontal" >

            <ImageView
                android:id="@+id/img"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="10dp"
                android:background="@drawable/video_notes" />

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="5dp"
                android:layout_toRightOf="@+id/img"
                android:text="@string/videoattach" />
        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/audiodetail"
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/edt_stroke_bg"
            android:orientation="horizontal"
            android:visibility="gone" >

            <ImageView
                android:id="@+id/imgaudio"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="10dp"
                android:background="@drawable/audio_notes" />

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="5dp"
                android:layout_toRightOf="@+id/imgaudio"
                android:text="Audio attachment" />
        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/drawingdetail"
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/edt_stroke_bg"
            android:orientation="horizontal"
            android:visibility="gone" >

            <ImageView
                android:id="@+id/drawing_img"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="10dp"
                android:background="@drawable/video_notes" />

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="5dp"
                android:layout_toRightOf="@+id/drawing_img"
                android:text="Drawing attachment" />
        </RelativeLayout>

        <LinearLayout
            android:id="@+id/edt_check"
            android:layout_width="fill_parent"
            android:layout_height="150dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/edt_stroke_bg"
            android:orientation="vertical"
            android:paddingStart="5dp" >

            <EditText
                android:id="@+id/body"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:background="@android:color/transparent"
                android:gravity="top"
                android:imeOptions="actionDone"
                android:paddingLeft="10dp"
                android:paddingRight="5dp"
                android:paddingTop="5dp" />
        </LinearLayout>
    </LinearLayout>
</ScrollView>

Is there is any properties for listview or any listeners to fix the issue? Thanks in advance.

Your design is incorrect. You should never put a ListView inside a ScrollView . ListView implements it own scrolling , and it won't receive any gesture as they are handled by the ScrollView . It won't work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM