【问题标题】:Translate animation relative to parent using xamarin使用 xamarin 相对于父级转换动画
【发布时间】:2016-12-04 02:18:55
【问题描述】:

我在 Java 中有以下代码,我在其中创建了一个相对于父级的翻译动画。什么是 Xamarin 等效代码? C# 中的 Animation 类似乎没有这些属性。任何帮助将不胜感激。

            Animation inFromBottom = new TranslateAnimation(
            Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 1.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f);

【问题讨论】:

  • 我看到你问了同样的问题here,那里的答案解决了你的问题吗?
  • 不,我仍然不明白如何指定动画相对于父级发生的事实。这些是我正在处理的动态组件。所以我需要使用代码而不是 xml 来做到这一点:(还有其他方法吗?
  • 我找到了 Xamarin 等效代码,你可以查看我的答案。

标签: c# android xamarin xamarin.android cross-platform


【解决方案1】:

在 Xamarin.Android 中,Animation.RELATIVE_TO_PARENTAnimation.RELATIVE_TO_SELF 等属性被封装到 Android.Views.Animations.Dimension Enumeration 中。

你可以像这样修改你的代码:

Animation inFromBottom = new TranslateAnimation(
Dimension.RelativeToParent, 0.0f,
Dimension.RelativeToParent, 0.0f,
Dimension.RelativeToParent, 1.0f,
Dimension.RelativeToParent, 0.0f);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-23
    • 2022-12-11
    • 2015-06-26
    • 1970-01-01
    • 2017-01-05
    • 2021-12-15
    相关资源
    最近更新 更多