问题描述
在一个活动我有以下几点:
VAR鳍= FindViewById< ViewFlipper>(Resource.Id.flipper);
flipper.Touch + = flipper_Touch;
基本实现触摸处理程序是这样的:
浮动oldTouchValue = 0;无效flipper_Touch(对象发件人,View.TouchEventArgs E)
{
VAR鳍=发件人为ViewFlipper;
开关(e.Event.Action)
{
案例MotionEventActions.Down:
oldTouchValue = e.Event.GetX();
打破; 案例MotionEventActions.Up:
浮currentX = e.Event.GetX();
如果(oldTouchValue< currentX)
{
flipper.ShowNext();
}
否则,如果(oldTouchValue> currentX)
{
flipper.Show previous();
}
打破;
}
}
这可以让我在不同的视图之间进行导航,但我想,使其滑动左/右
我已经看到了一些Java示例如何使它工作,但不是直接的方式把它翻译成C#。
什么是需要作出的意见滑动,有没有办法来定义动画
在 XML
?
我能够使活动的幻灯片和退出使用动画
在 XML ,并呼吁 OverridePendingTransition
,但我不知道如何在这里应用这些知识。
The ViewFlipper
has, through its ViewAnimator
class, some methods to set the animation for the in and out actions, setInAnimation()
and setOutAnimation()
. This are in the Android SDK but should have correspondence in MonoDroid(with which unfortunately I'm not familiar so I could be wrong). In order to have the desired animation simply use the two methods above to set the desired animations(either xml file or programmatically built Animation
) and then call the showNext/Previous
methods like you currently do.
You even have some slide animation in the Android SDK, but again I don't know if they are present in MonoDroid.
Update: Those methods are indeed available in Monodroid and exposed like this:
//Using one of the built in animations:
flipper.SetInAnimation(this, Android.Resource.Animation.SlideInLeft);
flipper.SetOutAnimation(this, Android.Resource.Animation.SlideOutRight);
//Using custom animations defined in XML
flipper.SetInAnimation(this, Resource.Animation.slide_in_right);
flipper.SetOutAnimation(this, Resource.Animation.slide_out_left);
这篇关于意见ViewFlipper之间的幻灯片动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!