2016-03-30 8 views
1

私は次の構造を有する:アニメイトレイアウト変更リサイクル業者は、表示はありません作業罰金

活動1:

<android.support.design.widget.CoordinatorLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/recycler_view" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:animateLayoutChanges="true"/> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/FAB_add" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"/> 

</android.support.design.widget.CoordinatorLayout> 

活動2:

<android.support.v7.widget.RecyclerView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/recycler_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:animateLayoutChanges="true"/> 
:RecyclerViewの

Form to add new item to the recycler View. 

XMLを

私はiを作成しますstartActivityForResultを使用してアクティビティ1に項目を追加し、次にadapter.notifyItemInserted(0)を呼び出します。

問題は、アイテムが追加され、挿入アニメーションが正しく機能しない場合ですが、2番目のアクティビティを使用せずに最初のアクティビティでアイテムを作成してアダプタに追加すると問題なく動作します。

¿この問題を解決するにはどうすればよいですか?

+0

あなたのメインCoordinatorLayout –

+0

にanimateLayoutChanges = "true"を追加します。それを試してみますが、FABが消えて後で表示しようとすると正しく動作せず、 "フラッシュ" –

答えて

1

あなたのXML構造は、私もあることがわかりましたthis blog

CoordinatorLayoutlayout_behaviorチェックを使用する方法の素敵なガイドについてあなたのlayout_behavior sおよびCoordinatorLayout Android CoordinatorLayout

の使用を確認し、問題がある可能性がありますandroid:animateLayoutChanges="true"の使用は、スクロール可能なRecyclerViewで非常にglitchy /バギーかもしれませんが、私はそれを使用しないことをお勧めします。スクロール不可能なRecyclerViewの場合、それはうまく動作します。

関連する問題