Android Recycler View notifyItemRemoved动画中断
Android Recycler View notifyItemRemoved animation cut off
我目前正在为 Java 编写 Android 6 的学校成绩经理。我刚开始使用 Android,所以我不是专家。
问题:
如果我在我的 RecycleView Adapter 上调用方法 notifyItemRemoved()
并且最后一个 CardView 从左下角移动到右上角,则 View 会调整大小并且动画会被剪切。
现在我不知道为什么要调整视图的大小,因为 RecycleView 的 layout_height
属性是 match_parent
。
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.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="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".SemesterActivity"
tools:showIn="@layout/activity_semester">
<android.support.v7.widget.RecyclerView
android:id="@+id/subject_list_view"
android:padding="20dp"
android:layout_below="@+id/title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"/>
</android.support.v4.widget.NestedScrollView>
我使用 GridLayoutManager
作为 RecycleView 的 LayoutManager。
subjectListView.setLayoutManager(new GridLayoutManager(ActivityContext, 2));
我如何更新 RecycleView:
SubjectAdapterObj.notifyItemRemoved(viewHolder.getAdapterPosition());
该动画为默认动画
GridLayoutManager
可能是问题所在吗?
视频示例:
对不起。英语不是我的母语。
所以我终于找到问题所在了。
它实际上是 NestedScrollView
调整它的大小 children.
所以你需要做的就是简单地将 android:fillViewport="true"
添加到你的 NestedScrollView
。
就是这样。我希望它对某人有所帮助,尽管这不是一个非常困难的错误。刚才找错地方了
我目前正在为 Java 编写 Android 6 的学校成绩经理。我刚开始使用 Android,所以我不是专家。
问题:
如果我在我的 RecycleView Adapter 上调用方法 notifyItemRemoved()
并且最后一个 CardView 从左下角移动到右上角,则 View 会调整大小并且动画会被剪切。
现在我不知道为什么要调整视图的大小,因为 RecycleView 的 layout_height
属性是 match_parent
。
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.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="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".SemesterActivity"
tools:showIn="@layout/activity_semester">
<android.support.v7.widget.RecyclerView
android:id="@+id/subject_list_view"
android:padding="20dp"
android:layout_below="@+id/title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"/>
</android.support.v4.widget.NestedScrollView>
我使用 GridLayoutManager
作为 RecycleView 的 LayoutManager。
subjectListView.setLayoutManager(new GridLayoutManager(ActivityContext, 2));
我如何更新 RecycleView:
SubjectAdapterObj.notifyItemRemoved(viewHolder.getAdapterPosition());
该动画为默认动画
GridLayoutManager
可能是问题所在吗?
视频示例:
对不起。英语不是我的母语。
所以我终于找到问题所在了。
它实际上是 NestedScrollView
调整它的大小 children.
所以你需要做的就是简单地将 android:fillViewport="true"
添加到你的 NestedScrollView
。
就是这样。我希望它对某人有所帮助,尽管这不是一个非常困难的错误。刚才找错地方了