Switch between actions: do not hide previous activity

Pretty simple question here, but I can not find someone who has already asked for it. Most likely, the correct keywords are not used.

Anyway, here is my scenario:

I am launching a new action in which I am showing a web view. I called overridePendingTransition to get the animation I want when I switch to a new activity that works fine (at least part of the animation works fine). However, there are a couple of things that distract from the effect.

I want the web view to slide on the previous action, below, and when the user clicks back, he needs to roll back from the site. The second part of this works like a charm, but the first part is not quite what I want.

Immediately after the start of a new action, the old one is hidden and black is in its place, so it seems like the webview is sliding in black. I would like it to leave the previous activity in the background instead of hiding it, so the webview slides over it. Is it possible?

Thanks!

+6
source share
5 answers

Create your custom transition XML resource files that achieve the desired effect, and call Activity.overridePendingTransition before starting the next action.

+1
source

I came here looking for the same, but the current answers did not help. Hope this helps, four months after the question was asked!

In my opinion, this is due to an error in the Android platform, because:

  • This only happens if exitAnim is 0,
  • this only happens with 'translate' elements. Alpha elements (attenuation, attenuation) work fine.

Here is my way:

@Override protected void onResume() { overridePendingTransition(R.anim.mu_slide_in_left, R.anim.mu_no_anim); super.onResume(); } @Override protected void onPause() { overridePendingTransition(0, R.anim.mu_slide_out_right); super.onPause(); } 

Where mu_no_anim.xml is

 <?xml version="1.0" encoding="utf-8"?> <alpha xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator" android:fromAlpha="1.0" android:toAlpha="1.0" android:duration="100000" /> 

Thus, it makes the activity continue to be visible, indicating a reliable alpha mechanism to take it from alpha-1 to alpha-1 for 100 seconds - in other words, just keep it fully visible.

The workaround is not entirely perfect. For example, if your new activity is called from a dialog box, the dialog box will look as if it was rejected as the activity slid into place, but it will return again after closing this operation.

+11
source

it may be slow, but have you tried using a different theme for this activity?

check this one out .

+1
source

Instead of using delayed exit animations, you can add a property to the input theme to make the window translucent so you can see previous activity.

 <style name="EnteringActivity.Theme" parent="@android:style/Theme.Holo.Light"> [...] <item name="android:windowIsTranslucent">true</item> [...] </style> 

Note. If you create a dialog activity, you will also need the following property in the action topic:

 <item name="android:windowBackground">@color/transparent</item> 
+1
source

I had a similar problem with the appearance of a black screen when switching from one action to another using the overridepending transition. and I went down the road and it worked

1) created noanim.xml in the animation folder

  <?xml version="1.0" encoding="utf-8"?> <translate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="@android:integer/config_longAnimTime" android:fromYDelta="0%p" android:toYDelta="0%p" /> 

and used

 overridePendingTransition(R.drawable.lefttorightanim, R.anim.noanim); 

the first parameter as my original animation and the second parameter which is the output animation as my dummy animation

+1
source

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


All Articles