如何在 Monodroid 中的活动之间制作从左到右的滑动动画? [英] How Do I Make a Swipe Animation From Left To Right Transition Between Activities In Monodroid?

查看:22
本文介绍了如何在 Monodroid 中的活动之间制作从左到右的滑动动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Monodroid 进行开发,并且希望能够在我这样做时向左或向右滑动并加载新活动.我还想要一个动画,显示下一个活动滑入屏幕,而其他活动滑出.

I'm developing using Monodroid and want to be able to swipe left or right and load new activities as I do so. I also want to have an animation that shows the next activity slide into the screen while the other slides out.

我已经尝试过使用 XML 资源文件以及实现动画的 OverridePendingTransition.然而,这些都不适合我.有没有人在这方面取得成功?你能把你的代码放在这里而不是某个博客或网站的链接吗?

I've tried OverridePendingTransition using XML resource files as well as implementing animations. None of this is working for me, however. Has anyone had success with this? Could you place your code here and not a link to some blog or website?

在我的所有活动中将其放入 OnCreate 中不起作用:

Putting this in OnCreate in all my activities does not work:

this.OverridePendingTransition(Resource.Animation.slide_in_right, Resource.Animation.slide_out_left);

XML 代码:

向右滑动:

<set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="false" >
<translate
    android:duration="200"
    android:fromXDelta="100%"
    android:fromYDelta="0%"
    android:toXDelta="0%"
    android:toYDelta="0%" />
</set>

向左滑出:

<set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="false" >
<translate
    android:duration="200"
    android:fromXDelta="100%"
    android:fromYDelta="0%"
    android:toXDelta="0%"
    android:toYDelta="0%" />
</set>

我还没有找到任何简单的代码来检测向左或向右滑动的手势.理想情况下,我希望能够拥有两个功能:

I haven't found any simple code to detect the gesture of swiping left or right. Ideally I'd like to be able to have two functions:

OnSwipeLeft()

OnSwipeRight()

然后我希望代码是一个简单的动画(当然我知道我需要使用这些函数来连接更多:

And then I'd hope the code is a simple for animation (of course I Know I need to hook into more with these functions:

AnimateSlideLeft();

AnimateSlideRight();

推荐答案

我的手机似乎没有启用动画,我必须转到我的 Android 手机上的设置并启用动画.一旦我这样做了,动画就起作用了.为此,请单击 Android 设置按钮(在我手机的左下方).点击设置"框.然后点击显示".然后点击动画".然后点击所有动画".一旦我这样做了,一切都奏效了.

It appears animations were not enabled on my phone and that I had to go to the settings on my Android phone and enable animations. Once I did this, the animations worked. To do this, click on the Android settings button (in the lower left for my phone). Tap the "Settings" Box. Then tap "Display". Then tap "Animation". Then tap "All animations". Once I did this, everything worked.

这篇关于如何在 Monodroid 中的活动之间制作从左到右的滑动动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆