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:
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);
}
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 );
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With