Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

how to add transition between activities android studio

Create a "CustomActivityAnimation" and add this to your base Theme by "windowAnimationStyle".

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorPrimary</item>
    <item name="android:windowAnimationStyle">@style/CustomActivityAnimation</item>

</style>

<style name="CustomActivityAnimation" parent="@android:style/Animation.Activity">
    <item name="android:activityOpenEnterAnimation">@anim/slide_in_right</item>
    <item name="android:activityOpenExitAnimation">@anim/slide_out_left</item>
    <item name="android:activityCloseEnterAnimation">@anim/slide_in_left</item>
    <item name="android:activityCloseExitAnimation">@anim/slide_out_right</item>
</style>



Then Create anim folder under res folder and then create this four animation 
files into anim folder:

slide_in_right.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromXDelta="100%p" android:toXDelta="0"
        android:duration="@android:integer/config_mediumAnimTime"/>
</set>

slide_out_left.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromXDelta="0" android:toXDelta="-100%p"
        android:duration="@android:integer/config_mediumAnimTime"/>
</set>

slide_in_left.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromXDelta="-100%p" android:toXDelta="0"
        android:duration="@android:integer/config_mediumAnimTime"/>
</set>

slide_out_right.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromXDelta="0" android:toXDelta="100%p"
        android:duration="@android:integer/config_mediumAnimTime"/>
</set>
Comment

PREVIOUS NEXT
Code Example
Java :: java main class 
Java :: java loop object 
Java :: decomposer chaine de caractère java 
Java :: print map in java 
Java :: sreekanth kasani 
Java :: papermc api maven 
Java :: add certificate to java truststore 
Java :: java current time millis 
Java :: retrofit dependency in android studio 
Java :: spring boot jpa in clause 
Java :: java convert list to page 
Java :: how to print two variables in same line in java 
Java :: how to instantiate hashmap in java 
Java :: how to convert int array to integer list in java 
Java :: calculate mean from arraylist jaca 
Java :: javafx object rectangle 
Java :: how to make an activity default in android studio 
Java :: Get the first day of the current month in Java 
Java :: rewrite file java 
Java :: android retrofit get @query 
Java :: How to add music to andoid project 
Java :: kill all java processes linux 
Java :: java program to print 1 to 100 using for loop 
Java :: java convert integer to string 
Java :: optional throw if present 
Java :: Error: Could not find or load main class -Djava.library.path=.home.hdoop.hadoop-3.3.0.lib.native 
Java :: javafx location is required 
Java :: android time 
Java :: HttpServer example java 
Java :: javafx stackpane set position 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =