我正在创建一个用户进入特定活动时显示的动画。基本上,此活动向上滑动以显示并向下滑动以关闭。我正在使用overridePendingTransition来实现这个动画。
但幻灯片有一个难看的效果。它可以在屏幕截图中看到:
查看正在关闭的活动上显示的灰色矩形。它为什么显示?
我认为这将是Android的android.R.id.content视图,所以我尝试更改其背景,但它没有用。
我正在使用ActionBarSherlock,代码如下所示:
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"/>
开始活动:
Intent intent = new Intent();
intent.setClass(getActivity(), PlayerActivity.class);
startActivity(intent);
getActivity().overridePendingTransition(R.anim.slide_in_from_bottom, R.anim.nothing);
结束活动:
@Override
public void onBackPressed() {
finish();
overridePendingTransition(R.anim.nothing, R.anim.slide_out_to_bottom);
}
答案 0 :(得分:5)
我在这里找到了问题的答案:
https://stackoverflow.com/a/6396465/1140713
我刚创建了一个BaseActivity,我的所有活动都是子类化,并在onCreate中添加了以下代码:
ColorDrawable colorDrawable = new ColorDrawable( Color.TRANSPARENT );
getWindow().setBackgroundDrawable( colorDrawable );
答案 1 :(得分:3)
这可能是因为你的notificationBar。您的下一个活动还有notificationBar,它带有空间。不确定,如果有任何解决方法......您可以尝试设置FullScreen,但当然这不是您想要的。