繁体   English   中英

Android Recycler View notifyItemRemoved动画已切断

[英]Android Recycler View notifyItemRemoved animation cut off

我目前正在使用Java for 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调整了其子级的大小。
因此,您需要做的只是将android:fillViewport="true"NestedScrollView

而已。 我希望它对某人有帮助,尽管这并不是一个真正困难的错误。 我只是在错误的地方搜索。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM