How can I get started with android material design animation on android

I am trying to create a custom android animation, so when I leave the activity, the new activity will expand from the button, matched like

example

Only I want the new activity to expand with the button pressed. Is there a way to do this on a device without 'android L'?

+3


source to share


2 answers


Yes, there is a way and it looks super sleek.

Basically there are 4 steps: 1. Make the 2nd activity transparent 2. Measure the size and position of the view you want to animate in the 1st activity and pass it to the second action in the kit 3. Animate the layout change in the 2nd action using the onPreDraw listing and data from the 1st activity. 4. Overwrite the default activity transitions



check out this DevByte , it explains exactly how to do it.

+3


source


Check class ActivityOptionsCompat. You can use it like this:

final ActivityOptionsCompat options = ActivityOptionsCompat.makeScaleUpAnimation(yourButton, 0, 0, 0, 0);
startActivity(activityStartingIntent, options.toBundle());

      



This should create a transition starting at the specified view and the specified starting size (which is 0 in this example).

+1


source







All Articles