Reputation: 219
Fairly straightforward question here, but I can't seem to find someone who has asked this already. Most likely not using the right keywords.
In any case, here is my scenario:
I am launching a new activity in which I show a web view. I have called overridePendingTransition in order to get the animation I want when I switch to the new activity, which works fine (at least, the animation part works fine). However, there are a couple things which take away from the effect.
What I want is to have the webview slide over the previous activity, from the bottom, and when the user presses back, it should slide back down out of site. The second part of this works like a charm, but the first part isn't exactly what I want.
Immediately upon triggering the new activity, the old one is hidden, and in its place is blackness, so it looks like the webview slides over blackness. I would like to have it leave the previous activity in the background instead of hiding it, so the webview slides over that. Is this possible?
Thanks!
Upvotes: 8
Views: 3682
Reputation: 615
I came here looking for the same thing but the current answers were no help. I hope this helps, being four months after the question was asked!
In my opinion, this is due to a bug in the Android platform because:
Here is my workaround:
@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" />
So this is forcing the out-going activity to stay visible by specifying the reliable alpha mechanism to fade it from alpha 1 to alpha 1 over 100 seconds - in otherwords, just keep it fully visible.
The workaround isn't completely perfect. For example, if your new Activity is called from a Dialog, the Dialog will look as if it is dismissed as the Activity slides into place - but it will be back again after closing that Activity.
Upvotes: 11
Reputation: 1373
I had a similar problem of getting a black screen appear on sliding transition from one activity to another using overridependingtransition. and I followed the way below and it worked
1) created a noanim.xml in anim 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 second parameter which is the exit animation as my dummy animation
Upvotes: 2
Reputation: 3090
Rather than using a delay exit animation, you can add a property to the entering activity's theme to make the window translucent - so you can see through to the previous activity.
<style name="EnteringActivity.Theme" parent="@android:style/Theme.Holo.Light">
[...]
<item name="android:windowIsTranslucent">true</item>
[...]
</style>
Note: if you are creating a dialog activity, you will also need the following property on the activity's theme:
<item name="android:windowBackground">@color/transparent</item>
Upvotes: 1
Reputation: 5410
Create your custom transition animation XML resource files that achieve the desired effect and call Activity.overridePendingTransition prior starting the next Activity.
Upvotes: 1
Reputation: 116362
it could be slow , but have you tried using a different theme for the activity ?
check this out.
Upvotes: 1