簡體   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