为什么我的共享元素转换停止工作?

Why has my shared element transition stopped working?

我的应用曾经有一个从片段到 activity 的共享元素转换。我不确定它何时停止工作。我做了一些小的代码更改,但没有影响转换周围的代码。我所做的最重要的事情是将我的支持库更新到 v24.2.1(从 v23.3.0)。我想知道我是否只是忽略了一些愚蠢的事情,或者支持库的变化是否起到了作用。相关代码片段如下:

启动共享元素转换的代码:

public void PreviewClicked(object sender, EventArgs e)
{
    var intent = new Intent(Activity, typeof(RoutineActivity));
    intent.PutExtra(RoutineBundleKeys.BLOB_ID, _selectedBlobId.ToString());
    intent.PutExtra(RoutineBundleKeys.ROUTINE_TITLE, _selectedTitle);
    intent.PutExtra(RoutineBundleKeys.ROUTINE_HTML, ViewModel.Html);

    if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
    {
        _selectedPreview.TransitionGroup = true;
        ActivityOptionsCompat options = ActivityOptionsCompat.MakeSceneTransitionAnimation(Activity, 
                                                                                           _selectedPreview, 
                                                                                           "webview_preview_transition");
        StartActivity(intent, options.ToBundle());
    }
    else
    {
        StartActivity(intent);
    }
}

以及正在共享的 XML 元素(上面代码段中的 _selectedPreview):

<WebView
    android:id="@+id/routine_preview"
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:gravity="center_vertical"
    android:scrollbars="none"
    android:transitionName="webview_preview_transition" />

OnCreate方法中整理Activity:

protected override void OnCreate(Bundle savedInstanceState)
{
    base.OnCreate(savedInstanceState);

    SetContentView(Resource.Layout.routine_activity_layout);

    _routineTitle = Intent.GetStringExtra(RoutineBundleKeys.ROUTINE_TITLE);

    var titleToolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.doc_title_toolbar);
    SetSupportActionBar(titleToolbar);
    SupportActionBar.Title = _routineTitle;

    _htmlString = Intent.GetStringExtra(RoutineBundleKeys.ROUTINE_HTML);

    if (_htmlString != null)
    {
        _routineView = FindViewById<WebView>(Resource.Id.routine_frame);

        if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
        {
            _routineView.TransitionGroup = true;
        }

        _routineView.Settings.BuiltInZoomControls = true;
        _routineView.Settings.DisplayZoomControls = false;

        string mimeType = "text/html";
        string encoding = "UTF-8";
        _routineView.LoadDataWithBaseURL("", _htmlString, mimeType, encoding, "");
    }
    else
    {
        var blobIdString = Intent.GetStringExtra(RoutineBundleKeys.BLOB_ID);
        _blobId = new Guid(blobIdString);

        RoutineFragment routineFragment = new RoutineFragment(_blobId);
        SupportFragmentManager.BeginTransaction().Replace(Resource.Id.routine_frame, routineFragment).Commit();
    }
}

而这个 Activity 的 XML:

<LinearLayout 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:id="@+id/nothing"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#000"
    android:orientation="vertical">

  <android.support.v7.widget.Toolbar
      android:id="@+id/doc_title_toolbar"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:background="?attr/colorPrimary"
      android:elevation="4dp"
      android:minHeight="?attr/actionBarSize"
      app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

  <WebView
      android:id="@+id/routine_frame"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:transitionName="webview_preview_transition" />
</LinearLayout>

在我的基本主题中,我有 <item name="android:windowContentTransitions">true</item>

我不知道问题可能是什么。好像一切都设置好了。

2017 年 2 月 2 日编辑:Xamarin 开发人员已确认这是一个错误。

我一直无法让它工作,但我怀疑它可能是 Xamarin 错误。我在 AndroidSupportComponents 问题跟踪器上找到了 this bug。显然它是在支持库的 rc1 中找到的,但我没有看到任何开发人员的响应。