javaandroidtransitionshared-element-transition

Shared Element Transition Between Activity And CustomDialog


I was wondering if there is any way to implement the Shared Element Transiition Between an Activity and a CustomDialog that I made. I know how it is implemented between 2 activities but wondering if this is possible between activity and dialog (JAVA).

Thanks.


Solution

  • You can make your own style for shared element transition like this,

    <style name="MyCustomTheme" parent="@android:style/Theme.Panel">
        <item name="android:windowAnimationStyle">@style/MyAnimation.Window</item>
    </style>
    
    <style name="MyAnimation.Window" parent="@android:style/Animation.Activity">
        <item name="android:windowEnterTransition">@anim/anim_in</item>
        <item name="android:windowExitTransition">@anim/anim_out</item>
    </style>
    

    and then put it on Dialog, like this:

    dialog = new Dialog(MainActivity.this, R.style.MyCustomTheme);
    

    hope can help you