Transition instead of simple Animation in Android

There is no need for animation effects on views in Android, no need for fast hardware for smooth transitions with these Transition features between activities giving your application stylish entrance.

We need two separate Activities and their layout, let say StartActivity and EndActivity. The first one will show only the app logo, and the second one will be Login form.

 

transition_gif

NOTE: We are going to use ButterKnife Library also for binding the Views from the XML, like buttons, text views, edit text etc.
ButterKnife by Jake Wharton Library with examples

StartActivity:

We have center logo ImageView and application name as TextView which will be translated into the EndActivity when user clicks on the Logo. (This may also be used as a SplashScreen).

There is one public static start method in both activities for starting each other.

Before starting next activity, a array of Pairs must be created. In our example there is two pairs that needs to be bonded, logo and app name. After binding the views, using (i strongly recommend) ButterKnife.bind method in onCreate, this views must be bonded with some king of keyword in the java code and in the xml views code. In this example we use “logo” and “app” keyword” in both the class and the layout, like android:transitionName=”appName” & android:transitionName=”logo”. The system knows how to make bond between this two views with the views in the SecondActivity also transition named after this two.
Then the Pairs are added in ActivityOptions object that we create to .makeSceneTransitionAnimation(), and the ActivityOptions object is used in the creation of the intent for starting next activitu, also with public static start method where it gets as parameters the context of the first activity and the ActivityOptions object for further processing of the transition.

EndActivity:

 

And in the end the layouts for the activities:

StartActivity layout:

 

EndActivity layout:

Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *