[英]RecyclerView scrolls up when items change
When Adapter submit a new list the screen scrolls up.当 Adapter 提交新列表时,屏幕会向上滚动。 How don't scroll the srcreen when submit a new list?
提交新列表时如何不滚动屏幕?
obs: setHasFixedSize(false) obs:setHasFixedSize(假)
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/design_default_color_on_primary">
...
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/matchesRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button1"
tools:itemCount="5"
tools:listitem="@layout/item_match" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.