Creating Android Animations with Motion Layout and Motion Editor

Creating Android Animations With MotionLayout And MotionEditor

Animation and lively graphics are something that catches the attention of the viewer quickly. Be it a website or applications the role of graphics and animation can’t be undermined. In fact, many of the applications like widgets have animations and graphics as the main element. Moreover, animation has been a part of the applications to make them more lively and engaging at the user end. Read this post here for full-stack Android development animation creation as an element and we see that Android animation has been a thing in demand.

Most of the Android applications that are being developed have a touch of animation in them. The incorporation of animation in Android apps is a part of the strategy to keep the user surrounded by a sense of attraction. Further, many Android applications use animation as a tool to connect with the users and to make them familiar with the interface. Irrespective of the purpose the use of animation has been increasing in Android development over the years. As a developer, if you are new to the domain of Android development then you must be aware of the animation in development. As you are doing the effort to read this post here we won’t disappoint you. Rather we would be discussing the same in-depth here.

Motion Editor

Just as you know that for development in Android you need an integrated development ecosystem or what we call Android suite for animation the case is the same. To create animation in Android apps you need a tool that can help in solving the purpose smoothly. Motion Editor is the tool that comes into play when we talk about animation in Android. The tool is an effective visual design editor for MotionLayout layout type. It makes it easy to create and purview animations before putting them into the app. It comes in its stable version in Android Studio 4.0.

The tool is basically an extension for the Android Studio’s layout editor. The tool is accessible when you open an XML file that has MotionLayout. The interactive layout editor tool helps you in editing and creating animations as per your needs. You can preview your creations and then integrate them with the application.  Now, as we have discussed the tool we would now look into the process of creation. That is we would try to look into how things work when you actually undertake a development project in the tool. For this, we would be looking at the process step by step. Yes, we would go in a step-by-step manner to help you understand and gain the real essence of the creation of animation for Android. And here we go.

Creating Animation 

To start with animation creation you should check that you have the latest version of Android Studio 4.0. If not then update it to the latest version of the Android Studio 4.0 before starting.

First Step 

The very first step requires you to be a bit familiar with the Motion Editor’s interface. You have to create a ConstraintLayout. To do this here are the steps required to be followed:

  • Firstly make sure that you have the repository declared in your top-level build.gradle file.
  • Next up you are required to add the library as a dependency in the module-level build.gradle.
  • Finally, you need to in the toolbar click on Sync Project with Gradle Files.
  • Now, it is all set to make the layout using the ConstraintLayout.

Make a right-click on the preview in the layout editor. Now, click on convert to MotionLayout. After this, the tool would convert it into MotionLayout, and the Motion Scene file (an .xml file with _scene appended to your layout filename) would be added to the directory of the XML file.

Second Step 

Now, the MotionLayout created in step one would be serving as the root layout and would appear in the Motion Editor UI. You should now switch to set start and end constraints. For this:

  • Select the start and end constraints in the overview panel.
  • In the selection, panel make a click on the pencil icon and then ‘Create Constraint’
  • Define the constraints as you desire from the attribute panel. Defining constraints is important as it helps us specify more attributes than the usual positions and bounds.
  • Define the interpolated attributes by adding them to the attribute panel. Or just simply do it via XML while defining the constraints.

Third Step 

In this step, there is a need to make the transition in order to perform the animation from the start to the end ConstraintSet. In the case of auto-generated MotionScene default, the transition is added.  To make the transition:

  • Select the transition arrow that is between the start and end states in the preview panel. Play or drag the current position in the selection panel.

Fourth Step 

This step involves the defining of the path. The default path is a straight line from the Start to End position which can be modified using KeyPosition. The steps to change path involves:

  • In the overview panel click transition
  • Now in the selection panel click on the timer icon and then KeyPosition
  • Select the desired view and properties as needed

Fifth Step

Here we modify the attributes as we perform the transition. Attributes like size, rotation, alpha, etc can be modified as we progress with the animation. To create KeyAttribute in the motion editor repeat the steps that we performed in step 4 to change the path.

Sixth Step

This is the final step before testing or what you can say pre-testing stage. To trigger the animation as we go on to test in on the device we would add an OnSwipe event.

Seventh Step 

The seventh step brings us to the end of the creation of the animation for the Android. That is, we can install the application on the device. Now, you can conduct your own device test and trial before you make the final launch of the app.

Animations Done Simply 

As we saw, animation in Android apps has become an important element and you can’t escape them for sure. Adding the animations and custom creation is made easy when you go by using the MotionLayout. This saves you from complicated codes and the need to have an experience of animation. The creation of animation is made quite easy with the tool and further, we can use graphical tool-making to make things further simplified. Therefore, you can opt for the MotionEditor tool without thinking much as you can create things as per need and without hassle which we saw just now.

Benefits Of App Animation

Since we have looked into the entire process of creating an Android app animation here it’s time we leave out this discussion with another meaningful insight. While for many app animations is a cool and go-to idea others don’t pay much attention to it. Keeping these aspects in mind we have tried to list some of the major benefits of having animation in the app.

  • Realism: The animation plays a very important role in creating realism at the user end. With animation, you can connect the user by sighting out some real-world connection. Say for example there is an app for online food ordering and delivery. Now, here the animation effect can be shown by an animated waiter taking the order. Further, the processing of the food order can be shown in real-time as in the kitchen or at the plating or packaging stage,  delivered, etc.
  • Information Collection: The animation play in the application can be used effectively to collect information from the users. Here the animation can be a part of making the user fill in certain details in regards to using up or registering on the app. Further, the information collected can be in the form of feedback that you want to generate from the user in regards to their experience on the app. A normal text-based reference asking for information or feedback would obviously be not having that potential to derive a response as that of an animated one.
  • Assistance Of User: The use of animation in an effective manner that can make the user experience better and also develops a connection with the app is the time when the user needs assistance. While the user looks for in-app assistance it is also a time for you to build a connection with the user ensuring him that the app and therefore the service provider is ready 24×7 to extend help. Here the use of chatbot is a great example. You can see many animated chatbots that interact with users online providing them answers 24 x7. Also, there are some AI (Artificial Intelligence) based virtual assistants who make the task easy like there is a real-time human executive at the other end. The chatbot animation can be best seen in the mobile banking apps which extend services online. The chatbots guide us effectively for all the bank account-related details. Further, the Google Assistant and Alexa are voice-based assistants whose technique can be adopted by giving them animated faces in the app.

Author Bio –

Hermit Chawla is a MD at AIS Technolabs which is a Web/App design and Development Company, helping global businesses to grow by Global Clients. He love to share his thoughts on Web & App Development, Clone App Development and Game Development.


Please enter your comment!
Please enter your name here