Мое приложение используется для перехода общего элемента из фрагмента в активность. Я не уверен, когда он прекратил работать. Я внес небольшие изменения в код, но ничего не влияет на код вокруг переходов. Самое большое, что я сделал, это обновить мои библиотеки поддержки до 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 метод в отделе Деятельность:
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();
}
}
И XML для этой Activi ти:
<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>
Я в недоумении, что может быть проблемой. Кажется, все настроено правильно.