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