13

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);
}
Fernando Camargo
  • 3,085
  • 4
  • 30
  • 49

2 Answers2

5

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 );
Community
  • 1
  • 1
Fernando Camargo
  • 3,085
  • 4
  • 30
  • 49
3

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.

yahya
  • 4,810
  • 3
  • 41
  • 58
  • Thank you for the answer. It was really the notificationBar. Anyway, I found another solution that doesn't need to set full screen: http://stackoverflow.com/a/6396465/1140713. I'll update the question soon. – Fernando Camargo Apr 12 '13 at 14:37
  • 1
    Ahh nice, didn't know that. Thanks for directing me as well :) – yahya Apr 12 '13 at 14:39