Running custom animations between Android actions

Therefore, I know that you can use your own animation between actions using the overidePendingTransition method. I set the transition between the two actions, and it works fine on my emulator, but I don't see the transition when I launch the application on my phone. How can it be?

2.2 works in my emulator since my phone

Here is my onCreate method

public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final Button button = (Button) findViewById(R.id.close); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent myIntent = new Intent(ActivityTransitionActivity.this, ActivityTwo.class); ActivityTransitionActivity.this.startActivity(myIntent); overridePendingTransition(R.anim.fadein, R.anim.fadeout); } }); } 
+6
source share
3 answers

In your .xml style, specify your animation

  <style name="Animation.CustomAnimation"> <item name="android:activityOpenEnterAnimation">@anim/slide_in_left</item> When opening a new activity, this is the animation that is run on the next activity <item name="android:activityOpenExitAnimation">@anim/slide_out_right</item>When opening a new activity, this is the animation that is run on the previous activity (which is exiting the screen) <item name="android:activityCloseEnterAnimation">@anim/slide_in_right</item>When closing the current activity, this is the animation that is run on the next activity (which is entering the screen). <item name="android:activityCloseExitAnimation">@anim/slide_out_left</item>When closing the current activity, this is the animation that is run on the current activity (which is exiting the screen). </style> <style parent="android:style/Theme.Light.NoTitleBar.Fullscreen" name="app_theme"> <item name="android:windowBackground">@drawable/splash</item> <item name="android:windowAnimationStyle">@style/Animation.CustomAnimation</item> </style> 

 <application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/app_theme"> 

apply app_theme to your application in android manifest

+11
source

I had the same problem (on samsung s galaxy). I found the answer in animation of activity not working in Galaxy Tab. It turns out that animations are disabled by default on samsung devices. (This is the parameter: go to Settings β†’ display β†’ animation, and then turn on the animation All, and you can see the animation)

+3
source

Try it,

  button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent myIntent = new Intent(v.getContext(), ActivityTwo.class); startActivityForResult(myIntent, 0); overridePendingTransition(R.anim.zoomextra, 0); finish(); } }); 
0
source

Source: https://habr.com/ru/post/895936/


All Articles