0

Hi I'm Stefan and I'm working on a project now and I would like to introduce the following functionality.The functionality consists of an animated transition that starts from the button that expands into a new activity.

I drew to explain better: enter image description here

Theoretically I want to make an animated transition from one activity to another in which I want to search (editText) data and go back with the result, this can be found in applications such as Waze, Youtube, etc.

How would you do in Android Studio Java [code]? Thanks in advance.

1 Answers1

0

In order to add animation between the transition from Activity A to Activity B, you need to follow below steps:

Step 1: Create animations inside directory res/anim folder.
A sample Fade In animation looks like below:
FileName: fade_in.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- Fade In Animation -->
<set xmlns:android="http://schemas.android.com/apk/res/android">
   <alpha
       android:duration="@android:integer/config_mediumAnimTime"
       android:fromAlpha="0.0"
       android:toAlpha="1.0" />
</set>

Step 2: Add the above animation in your code, while navigating to another activity

startActivity(new Intent(MainActivity.this, NameOfSecondActivity.class));
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);

Please refer to this link, which consist of an already answered question on various ways to add animation.
Please go through all the answers to get fair understanding of the concept.

Add Animation While Navigating to Another Activity

SVK
  • 676
  • 1
  • 5
  • 17