How to change TextView size in scene transition animation?

时间:2017-12-18 07:19:56

标签: android animation

Please help me with scene transition animation settings.

This is my idea: enter image description here

When I click on the TextView (FirstActivity) I want share this TextView to SecondActivity with view size changing and moving.

When I open (or close) SecondActivity my TextView moving (by arrow #1 or #2) but without size changing. And this looked ugly.

This is my code:

Theme (I use this theme for both FirstActivity and SecondActivity):

<style name="AppTheme.MaterialAnimation.SharedViews">
    <item name="android:windowContentTransitions">true</item>

    <item name="android:windowSharedElementEnterTransition">@transition/enter_shared_ui</item>
    <item name="android:windowSharedElementExitTransition">@transition/exit_shared_ui</item>
</style>

enter_shared_ui.xml:

 <?xml version="1.0" encoding="utf-8"?>
    <transitionSet xmlns:android="http://schemas.android.com/apk/res/android"
        android:duration="4000"
        android:interpolator="@android:interpolator/decelerate_cubic">

        <changeBounds />
    </transitionSet>

exit_shared_ui.xml

  <?xml version="1.0" encoding="utf-8"?>
    <transitionSet xmlns:android="http://schemas.android.com/apk/res/android"
        android:duration="4000"
        android:interpolator="@android:interpolator/decelerate_cubic">

        <changeBounds />
    </transitionSet>

How to change TextView size changing in my scene transition animation?

UPDATE:

This code for launching SecondActivity:

    private fun openSecondScreen() {
    val intent = Intent(this, SharedUIFinishActivity::class.java)
    ... // add another views to Pair
    val thirdPair = Pair(tvSharedUISelect as View, getString(R.string.shared_ui_text))
    val options = ActivityOptions.makeSceneTransitionAnimation(this,
                    ... thirdPair)

    startActivity(intent, options.toBundle())
}

And for both TextView's I use the same transition name.

1 个答案:

答案 0 :(得分:1)

To make the library(dplyr) Table_3 <- Table_2 %>% left_join(Table_1, by = c("Name", "Age")) to work, you have to set the same transition names to both the TextView in Activity1 and Activity2.

make sure the names are same, so that the framework can know to which the transition has to happen.

SharedElementTransition

in Activity1 to start Activity2

<TextView
    ...
    android:transitionName="my_transition"/>
相关问题