简体   繁体   English

Xamarin.Forms Animations 中的“屏幕外”和“屏幕上”是什么?

[英]What is "off screen" and "on screen" in Xamarin.Forms Animations?

In the docs for TranslateTo it says:TranslateTo的文档中,它说:

To animate a view that receives user touch input from outside of the screen, the developer must first lay out the view in its final position, then translate the view off screen, and then finally animate the view back to its final position on the screen .要动画从屏幕外部接收用户触摸输入的视图,开发人员必须首先将视图布局在其最终位置,然后将视图平移到屏幕外,最后将视图动画回其在屏幕上的最终位置 [emphasis mine] [强调我的]

Also in Simple Animations in Xamarin.Forms (in the Note) it says:同样在Xamarin.Forms中的简单动画(在注释中)它说:

If an element is initially laid out off screen and then translated onto the screen, after translation the element's input layout remains off screen and the user can't interact with it.如果一个元素最初在屏幕外布局,然后被翻译到屏幕上,则翻译后元素的输入布局保持在屏幕外,用户无法与其交互。 Therefore, it's recommended that a view should be laid out in its final position, and then any required translations performed .因此,建议将视图布局在其最终位置,然后执行任何所需的转换 [emphasis mine] [强调我的]

What does that mean in code?这在代码中是什么意思?

According to a comment above , it seems like the answer is that we need to:根据上面的评论,答案似乎是我们需要:

child.X = <destination (which is somewhere that the user can see)>
child.TranslateX = <somewhere not seen>
child.TranslateTo(0)

(pseudo code as I can't test it at this moment) (伪代码,因为我现在无法测试它)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM