Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Activity Slow transition

I want to remove the old activity from stack after clicking on a button that triggers an intent to a new activity. The problem is: The transition is not smooth like a normal transition. For like a half second the screen is completely white. How to make this smooth?

button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {

         Intent intent = new Intent(MainActivity.this, HomeActivity.class);
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
         startActivity(intent);
    }
});
like image 889
XxGoliathusxX Avatar asked Jun 26 '26 16:06

XxGoliathusxX


1 Answers

Use: Activity.overridePendingTransition(). Define simple transition animations with XML file.

Remmember this 4 atributes:

android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="0.0"
 android:toAlpha="1.0"
 android:duration="2000"

This atributtes make "smooth" transition

like image 66
josedlujan Avatar answered Jun 28 '26 14:06

josedlujan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!