Reputation: 1005
I am using Apis 's deme for slide-in and slide-out between two activity. But when I jump from one activity to another a black screen is appearing.
Slide-Left-
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator" >
<translate
android:duration="300"
android:fromXDelta="100%p"
android:toXDelta="0" />
</set>
Slide-Right-
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator" >
<translate
android:duration="300"
android:fromXDelta="-100%p"
android:toXDelta="0" />
</set>
To Jump from one activity to another:-
Button button1 = (Button) findViewById(R.id.Button01);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
startActivity(new Intent(getApplicationContext(), SecondView.class));
overridePendingTransition(R.anim.slide_left, R.anim.slide_right);
});
Why is this black screen is appearing between two activity.
Upvotes: 1
Views: 7002
Reputation: 508
Your first xml should be like:
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator" >
<translate
android:duration="300"
android:fromXDelta="0"
android:toXDelta="100%p" />
</set>
fromXDelta is the horizontal translation applied at the beginning of the animation. Setting it to "100%p" makes the first activity shift just right out of the screen at the inception of the animation, hence the blank screen.
The call to the function overridePendingTransition(int, int)
should be like this:
overridePendingTransition(R.anim.slide_right, R.anim.slide_left);
The first argument determines the transition animation used by the second activity. Also the two animations can be more properly named as slide_out_to_right and slide_in_from_left, since in fact they all slide to the right.
Upvotes: 8