How Do I Make a Swipe Animation From Left To Right Transition Between Activities In Monodroid?

佐手、 提交于 2020-01-21 18:15:12

问题


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.

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?

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

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

XML code:

Slide in right:

<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>

Slide out left:

<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();

回答1:


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.



来源:https://stackoverflow.com/questions/13212610/how-do-i-make-a-swipe-animation-from-left-to-right-transition-between-activities

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!