【发布时间】:2022-01-01 12:52:48
【问题描述】:
当适配器提交新列表时,屏幕会向上滚动。提交新列表时如何不滚动屏幕?
obs: setHasFixedSize(false)
<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>
【问题讨论】:
标签: android android-layout android-recyclerview