Android ScrollView嵌套GridView或者ListView的时候,页面自动滚动到GridView或者ListView所在位置的问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010872619/article/details/78143141

布局文件:

<ScrollView
        android:id="@+id/ptrsl"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <ImageView
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="10dp"
                android:src="@drawable/mz8"/>

            <com.jd.jdvip.widget.GridViewForScrollView
                android:id="@+id/benefit_gv"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="5dp"
                android:horizontalSpacing="5dp"
                android:numColumns="2"
                android:overScrollMode="never"
                android:verticalSpacing="5dp">

            </com.jd.jdvip.widget.GridViewForScrollView>

        </LinearLayout>
    </ScrollView>

解决办法:在ScrollView的子布局LinearLayout加上属性

android:focusable="true"
android:focusableInTouchMode="true"

猜你喜欢

转载自blog.csdn.net/u010872619/article/details/78143141