13

我正在创建一个动画,以便在用户进行特定活动时显示。基本上,此活动向上滑动以显示,向下滑动以关闭。我正在使用 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"/>

什么都没有.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);
}
4

2 回答 2

5

我在这里找到了我的问题的答案:

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

我刚刚创建了一个 BaseActivity,我的所有活动都是子类,并在 onCreate 中添加了以下代码:

ColorDrawable colorDrawable = new ColorDrawable( Color.TRANSPARENT );
getWindow().setBackgroundDrawable( colorDrawable );
于 2013-04-15T13:51:51.950 回答
3

这可能是因为您的通知栏。你的下一个活动也有通知栏,它带有它的空间。不确定,如果有任何解决方法...您可以尝试设置 FullScreen 但当然这不是您想要的。

于 2013-04-12T14:27:52.890 回答