美文网首页
解决ScrollView自动滚动到底部的问题

解决ScrollView自动滚动到底部的问题

作者: 小智在不在 | 来源:发表于2019-04-16 15:12 被阅读0次

在使用ScrollView时如果ScrollView内有ListView或者RecyclerView等View时会发生直接滚动到底部的问题,这个时候可以将ScrollView上部显示的某个View的focusable属性和focusableInTouchMode属性设置为true,例如:

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

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

                <android.support.constraint.ConstraintLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:focusable="true"
                    android:focusableInTouchMode="true"/>

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/recycler_view"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="38.5dp"/>
            </LinearLayout>
</ScrollView>

相关文章

网友评论

      本文标题:解决ScrollView自动滚动到底部的问题

      本文链接:https://www.haomeiwen.com/subject/orubwqtx.html