Skip to content

Instantly share code, notes, and snippets.

@NinoDLC
Created December 15, 2021 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NinoDLC/8fc586f47f7c7689cad54c380db373f5 to your computer and use it in GitHub Desktop.
Save NinoDLC/8fc586f47f7c7689cad54c380db373f5 to your computer and use it in GitHub Desktop.
Intent intent = MeetingDetailActivity.navigate(this, meetingId);
Pair<View, String> imageViewPair = new Pair<>(imageView, imageView.getTransitionName());
Pair<View, String> textViewPair = new Pair<>(textView, textView.getTransitionName());
@SuppressWarnings("unchecked")
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(
this,
imageViewPair,
textViewPair
);
startActivity(intent, options.toBundle());
roomImageView.setTransitionName(getMeetingRoomTransitionName(meetingId));
topicTextView.setTransitionName(getMeetingTopicTransitionName(meetingId));
<?xml version="1.0" encoding="utf-8"?>
<transitionSet
xmlns:android="http://schemas.android.com/apk/res/android">
<targets>
<target android:excludeId="@android:id/statusBarBackground" />
<target android:excludeId="@android:id/navigationBarBackground" />
<target android:excludeId="@id/appbarlayout" />
</targets>
<autoTransition />
</transitionSet>
<?xml version="1.0" encoding="utf-8"?>
<transitionSet
xmlns:android="http://schemas.android.com/apk/res/android">
<targets>
<target android:excludeId="@android:id/statusBarBackground" />
<target android:excludeId="@android:id/navigationBarBackground" />
<target android:excludeId="@id/appbarlayout" />
</targets>
<fade />
</transitionSet>
<?xml version="1.0" encoding="utf-8"?>
<transitionSet
xmlns:android="http://schemas.android.com/apk/res/android"
android:startDelay="300">
<targets>
<target android:excludeId="@android:id/statusBarBackground" />
<target android:excludeId="@android:id/navigationBarBackground" />
<target android:excludeId="@id/appbarlayout" />
</targets>
<fade />
</transitionSet>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<!-- enable window content transitions (shared element transition) -->
<item name="android:windowActivityTransitions">true</item>
<item name="android:windowEnterTransition">@transition/fade_delay</item>
<item name="android:windowReenterTransition">@transition/fade_delay</item>
<item name="android:windowReturnTransition">@transition/fade</item>
<item name="android:windowExitTransition">@transition/fade</item>
<item name="android:windowSharedElementEnterTransition">@transition/autotransition</item>
<item name="android:windowSharedElementExitTransition">@transition/autotransition</item>
</style>
</resources>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment