【发布时间】:2016-08-04 11:42:10
【问题描述】:
我是 Xamarin Android 编程以及一般 Android 编程的初学者。我成功运行了以下代码,达到了预期的效果:
//in the context of the main Activity
StartActivity(someIntent);
OverridePendingTransition(Android.Resource.Animation.SlideInLeft,
Android.Resource.Animation.SlideOutRight);
现在我想创建自己的动画,用于使用 XML 声明从左侧滑出和从右侧滑出。我将我的 XML 文件放在 anim 文件夹下,分别命名为 slideInLeft.xml 和 slideOutRight.xml。以下是文件内容:
slideInLeft.xml:
<?xml version="1.0" encoding="utf-8" ?>
<translate xmlns:android="http://schemes.android.com/apk/res/android"
android:duration="300"
android:fromXDelta="-100%"
android:toXDelta="0%">
</translate>
slideOutRight.xml:
<?xml version="1.0" encoding="utf-8" ?>
<translate xmlns:android="http://schemes.android.com/apk/res/android"
android:duration="350"
android:fromXDelta="0%"
android:toXDelta="100%">
</translate>
现在代码只是简单地改成这样:
//in the context of the main Activity
StartActivity(someIntent);
OverridePendingTransition(Resource.Animation.SlideInLeft,
Resource.Animation.SlideOutRight);
但是动画不起作用,新的 Activity 只是在短暂的延迟后显示(看起来等于滑动的持续时间,即 300ms)。
这让我很困惑。我不知道为什么以及如何做到这一点。
【问题讨论】:
标签: java c# android animation xamarin