Java 在RecyclerView中滚动
有这样一种布局:Java 在RecyclerView中滚动,java,android,layout,scrollview,Java,Android,Layout,Scrollview,有这样一种布局: <LinearLayout 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:la
<LinearLayout
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:orientation="vertical">
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/dateTV"
tools:context=".DayTasksActivity"
tools:layout_editor_absoluteX="1dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/RWTasksOnDay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="16dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:padding="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/RWTasksOnDay">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/taskET"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textPersonName" />
<com.google.android.material.button.MaterialButton
android:id="@+id/addTaskBTN"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
android:enabled="false"
android:text="@string/add_task" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</LinearLayout>
当您单击将新项目添加到RecyclerView时,您需要添加滚动到新项目的滚动视图,直到底部。使用fullScroll well,结果是达到了预期的结果,或者做了一些错误的事情。
请告诉我如何解决这个问题。滚动RecyclerView怎么样?您可以使用滚动键将其滚动到最后一项
your_recycler.scrollToPosition(last_item_index)
您可以在recyclerview中实现这一点,即使用scrollToPosition()或smoothScrollToPosition()谢谢,明白了。因此,必须删除ScrollView
your_recycler.scrollToPosition(last_item_index)