How to apply slide animation between two activities in Android

How to apply slide animation between two activities in Android - Hello friend inabnomaniiyaha, In the article that you read this time with the title How to apply slide animation between two activities in Android, we have prepared this article well for you to read and take information in it. hopefully the contents of the post Artikel Android,what we write you can understand. Alright, happy reading.

Judul : How to apply slide animation between two activities in Android
link : How to apply slide animation between two activities in Android

Baca juga


How to apply slide animation between two activities in Android

 I want to achieve a sliding effect from left to right when I move from one activity to another. For that I am using the following code, but I am not getting any results. Please correct me.


How to apply slide animation between two activities in Android

You can overwrite your default activity animation and it perform better than overridePendingTransition. I use this solution that work for every android version. Just copy paste 4 files and add a 4 lines style as below: 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>

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>

 



That's the articleHow to apply slide animation between two activities in Android

That's it for the article How to apply slide animation between two activities in Android this time, hopefully can be useful for all of you. well, see you in another article post.

You are now reading the articleHow to apply slide animation between two activities in Android with link addresshttps://inabnonapudyawanabing.blogspot.com/2020/11/how-to-apply-slide-animation-between.html

0 Response to "How to apply slide animation between two activities in Android"

Post a Comment

Tips Tricks for Android Phone

Tips & Tricks for Android Phone is a free android app and Collection of Tips and Tricks related to using your android mobile device lik...