Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activity's slide animation with overridePendingTransition having an strange effect

I'm creating an animation to be displayed when the user goes to a specific activity. Basically, this activity slides up to be showed and slides down to be closed. I'm using overridePendingTransition to make this animation happen.

But there's an ugly effect with the slide. It can be seen in the screen shot: Screen shot

Look at that gray rectangle shown on the activity being closed. Why is it shown?

I thought it would be the android.R.id.content view of Android, so I tried to change its background, but it didn't work.

I'm using ActionBarSherlock and the code is shown below:

slide_in_from_bottom.xml

<translate xmlns:android="http://schemas.android.com/apk/res/android"
           android:fromYDelta="100%p"
           android:toYDelta="0%p"
           android:duration="@android:integer/config_mediumAnimTime"/>

slide_out_to_bottom.xml

<translate xmlns:android="http://schemas.android.com/apk/res/android"
           android:fromYDelta="0%p"
           android:toYDelta="100%p"
           android:duration="@android:integer/config_mediumAnimTime"/>

nothing.xml

<alpha xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="0" android:fromAlpha="1" android:toAlpha="1"/>

Starting the activity:

Intent intent = new Intent();
intent.setClass(getActivity(), PlayerActivity.class);
startActivity(intent);

getActivity().overridePendingTransition(R.anim.slide_in_from_bottom, R.anim.nothing);

Closing the activity:

@Override
public void onBackPressed() {
    finish();
    overridePendingTransition(R.anim.nothing, R.anim.slide_out_to_bottom);
}
like image 365
Fernando Camargo Avatar asked Apr 12 '13 14:04

Fernando Camargo


2 Answers

I found the answer for my problem here:

https://stackoverflow.com/a/6396465/1140713

I just created a BaseActivity that all my Activities is subclassing and added the following code in the onCreate:

ColorDrawable colorDrawable = new ColorDrawable( Color.TRANSPARENT );
getWindow().setBackgroundDrawable( colorDrawable );
like image 76
Fernando Camargo Avatar answered Oct 24 '22 04:10

Fernando Camargo


That is probably because of your notificationBar. Your next activity has also notificationBar, and it comes with its space. Not sure, if there is any work out for this... You may try to set FullScreen but of course this is not what you wish.

like image 44
yahya Avatar answered Oct 24 '22 04:10

yahya