Android 共享元素转换在棉花糖中不起作用

Android 共享元素转换在棉花糖中不起作用,android,android-6.0-marshmallow,Android,Android 6.0 Marshmallow,我在棒棒糖中使用了共享元素转换,但现在我的手机升级到棉花糖,转换不再正常工作。从“活动A”到“活动B”的转换按预期工作,但当按“后退”返回到“活动A”时,转换工作,然后两个共享元素视图在屏幕外动画显示 活动A: Intent flashcardIntent = new Intent(this, FlashcardActivity.class); flashcardIntent.putExtra(getString(R.string.study_id), flashcardSetI

我在棒棒糖中使用了共享元素转换,但现在我的手机升级到棉花糖,转换不再正常工作。从“活动A”到“活动B”的转换按预期工作,但当按“后退”返回到“活动A”时,转换工作,然后两个共享元素视图在屏幕外动画显示

活动A:

Intent flashcardIntent = new Intent(this, FlashcardActivity.class);
        flashcardIntent.putExtra(getString(R.string.study_id), flashcardSetId.toString());
        flashcardIntent.putExtra(getString(R.string.flashcard_calling_activity), FlashcardActivity.SUBJECT_LIST);
        ArrayList<Pair<View, String>> sharedElements = new ArrayList<>();
        sharedElements.add(new Pair<View, String>(titleView, getString(R.string.transition_set_title)));
        sharedElements.add(new Pair<View, String>(toolBar, getString(R.string.transition_toolbar)));
        FlashcardSet set = FlashcardSetService.getInstance().getFlashcardSet(flashcardSetId);
        if( set.isQuizletSet() )
        {
            sharedElements.add(new Pair<View, String>(quizletImage, getString(R.string.transition_quizlet_image)));
        }
        sharedElements.add(new Pair<View, String>(setCard, getString(R.string.transition_set_card)));
        sharedElements.add(new Pair<View, String>(cardCount, getString(R.string.transition_card_count)));
        ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(
                // the context of the activity
                this,
                // For each shared element, add to this method a new Pair item,
                // which contains the reference of the view we are transitioning *from*,
                // and the value of the transitionName attribute
                sharedElements.toArray(new Pair[sharedElements.size()])
        );

        ActivityCompat.startActivity(MainFlashcardSetListActivity.this, flashcardIntent, options.toBundle());
Intent flashcardIntent=新的Intent(这是FlashcardActivity.class);
FlashCardContent.putExtra(getString(R.string.study_id)、flashcardSetId.toString());
FlashCardContent.putExtra(getString(R.string.flashcard\u calling\u activity)、FlashcardActivity.SUBJECT\u LIST);
ArrayList sharedElements=新的ArrayList();
添加(新对(titleView,getString(R.string.transition\u set\u title));
添加(新的一对(工具栏,getString(R.string.transition\u工具栏));
FlashcardSet=FlashcardSetService.getInstance().getFlashcardSet(flashcardSetId);
if(set.isQuizletSet())
{
添加(新对(quizletImage,getString(R.string.transition\u quizlet\u image));
}
添加(新对(setCard,getString(R.string.transition\u set\u card));
添加(新对(cardCount、getString(R.string.transition\u card\u count));
ActivityOptions Compat options=ActivityOptions Compat.MakeScenetTransitionAnimation(
//活动的背景
这
//对于每个共享元素,在此方法中添加一个新的Pair项,
//其中包含我们从*转换*的视图的引用,
//以及transitionName属性的值
sharedElements.toArray(新对[sharedElements.size()])
);
ActivityCompat.startActivity(MainFlashcardSetListActivity.this、FlashCardContent、options.toBundle());
布局A:

<LinearLayout
    android:id="@+id/test_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <RelativeLayout
        android:id="@+id/test_relative_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical">

        <ImageButton
            android:id="@+id/delete_item"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_delete"
            android:background="?android:selectableItemBackground"
            android:layout_alignParentRight="true"
            android:layout_alignParentEnd="true"
            android:layout_marginTop="6dip"
            android:layout_marginRight="6dip"/>

        <com.bmb.kangaroo.views.NotePaperTextView
            android:id="@+id/note_list_title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="4dip"
            android:layout_marginTop="16dip"
            android:paddingLeft="14dip"
            android:paddingRight="14dip"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:transitionName="@string/transition_set_title"
            android:layout_alignParentStart="true"
            android:layout_alignParentLeft="true"/>
    </RelativeLayout>

    <com.bmb.kangaroo.views.NotePaperTextView
        android:id="@+id/note_list_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dip"
        android:layout_marginTop="4dip"
        android:ellipsize="end"
        android:maxLines="5"
        android:minLines="1"
        android:paddingEnd="16dip"
        android:paddingStart="16dip"
        android:scrollHorizontally="false"
        android:transitionName="@string/transition_card_count"
        android:textAppearance="?android:attr/textAppearanceSmall"/>

    <ImageView
        android:id="@+id/set_from_quizlet"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/quizlet_icon"
        android:layout_marginTop="12dip"
        android:layout_gravity="end"
        android:transitionName="@string/transition_quizlet_image"
        android:visibility="invisible"
        android:contentDescription="@string/from_quizlet"/>
</LinearLayout>

布局B:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.Toolbar
        android:id="@+id/flashcard_toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/colorPrimary"
        android:transitionName="@string/transition_toolbar">

    </android.support.v7.widget.Toolbar>

    <com.bmb.kangaroo.views.NotePaperLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginTop="14dip"
        android:layout_marginLeft="14dip"
        android:layout_marginStart="14dip"
        android:transitionName="@string/transition_set_card"
        android:layout_below="@id/flashcard_toolbar"/>

    <com.bmb.kangaroo.views.NotePaperLayout
        android:id="@+id/flashcard_set_title_card"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginTop="14dip"
        android:layout_marginLeft="14dip"
        android:layout_marginStart="14dip"
        android:layout_below="@id/flashcard_toolbar"
        android:visibility="invisible">

        <LinearLayout
            android:id="@+id/test_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <RelativeLayout
                android:id="@+id/test_relative_layout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="center_vertical">

                <ImageButton
                    android:id="@+id/delete_set"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_delete"
                    android:background="?android:selectableItemBackground"
                    android:layout_alignParentRight="true"
                    android:layout_alignParentEnd="true"
                    android:layout_marginTop="6dip"
                    android:visibility="invisible"
                    android:layout_marginRight="6dip"/>

                <com.bmb.kangaroo.views.NotePaperTextView
                    android:id="@+id/flashcard_set_title"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="4dip"
                    android:layout_marginTop="16dip"
                    android:paddingLeft="14dip"
                    android:paddingRight="14dip"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:transitionName="@string/transition_set_title"
                    android:layout_alignParentStart="true"
                    android:layout_alignParentLeft="true"/>
            </RelativeLayout>

            <com.bmb.kangaroo.views.NotePaperTextView
                android:id="@+id/flashcard_count"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="16dip"
                android:layout_marginTop="4dip"
                android:ellipsize="end"
                android:maxLines="5"
                android:minLines="1"
                android:paddingLeft="16dip"
                android:paddingRight="16dip"
                android:scrollHorizontally="false"
                android:transitionName="@string/transition_card_count"
                android:textAppearance="?android:attr/textAppearanceSmall"/>

            <ImageView
                android:id="@+id/set_from_quizlet"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/quizlet_icon"
                android:layout_marginTop="12dip"
                android:layout_gravity="end"
                android:transitionName="@string/transition_quizlet_image"
                android:contentDescription="@string/from_quizlet"
                android:visibility="invisible"/>
        </LinearLayout>

    </com.bmb.kangaroo.views.NotePaperLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/flashcard_pager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/flashcard_set_title_card"
        android:layout_gravity="center_vertical"/>

    <com.getbase.floatingactionbutton.FloatingActionsMenu
        android:id="@+id/flashcard_floating_menu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="16dip"
        android:layout_marginEnd="16dip"
        android:layout_marginRight="16dip"
        res:fab_addButtonColorNormal="@color/accent_color"
        res:fab_addButtonColorPressed="@color/accent_color_pressed"
        res:fab_addButtonPlusIconColor="@android:color/white"
        res:fab_labelStyle="@style/menu_labels_style">

        <com.getbase.floatingactionbutton.FloatingActionButton
            android:id="@+id/add_new_flashcard_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            res:fab_colorNormal="@color/accent_color"
            res:fab_colorPressed="@color/accent_color_pressed"
            res:fab_icon="@drawable/create"
            res:fab_title="@string/add_flashcard"/>

        <com.getbase.floatingactionbutton.FloatingActionButton
            android:id="@+id/export_to_quizlet_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            res:fab_colorNormal="@color/accent_color"
            res:fab_colorPressed="@color/accent_color_pressed"
            res:fab_icon="@drawable/upload"
            res:fab_title="@string/export_to_quizlet"/>

        <com.getbase.floatingactionbutton.FloatingActionButton
            android:id="@+id/share_flashcards_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            res:fab_colorNormal="@color/accent_color"
            res:fab_colorPressed="@color/accent_color_pressed"
            res:fab_icon="@drawable/share"
            res:fab_title="@string/share_flashcards"/>

    </com.getbase.floatingactionbutton.FloatingActionsMenu>

</RelativeLayout>

有人遇到过这种行为吗?或者注意到代码有问题