2016-09-01 71 views
1

我目前正在爲使用Android 6.0編寫的Java學校的成績管理器工作。我剛開始使用Android,所以我不是專家。Android Recycler查看notifyItemRemoved動畫截圖

問題:
如果我呼籲我的RecycleView適配器的方法notifyItemRemoved(),並從左下地方最後CardView移動到右上角的地方,視圖大小,而動畫被切斷的。

現在我不知道爲什麼這個視圖被調整大小,因爲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。

subjectListView.setLayoutManager(new GridLayoutManager(ActivityContext, 2)); 

我如何更新RecycleView:

SubjectAdapterObj.notifyItemRemoved(viewHolder.getAdapterPosition()); 

動畫是默認的動畫。

難道GridLayoutManager是問題嗎?

視頻示例:

Animation cut off

對不起。英語不是我的母語。

+0

什麼是您正在使用的recyclerview版本? – Abbas

+0

recycleview-v7-23.4.0它是什麼意思? – Velrest

+0

嘗試覆蓋'RecyclerView'的'onMeasure'並設置最大高度。 – Abbas

回答

2

所以我終於找出問題所在。
它實際上是調整它的孩子的NestedScrollView。
所以你需要做的只是添加android:fillViewport="true"到你的NestedScrollView。

就是這樣。我希望它能幫助某人,儘管這不是一個非常困難的錯誤。我剛剛在錯誤的地方搜索。