【问题标题】:android animated menu backgroundandroid动画菜单背景
【发布时间】:2013-04-25 14:30:04
【问题描述】:

我目前正在开发另一个 Android 应用程序。它确实有一个主菜单。到目前为止,它非常简单 - 里面有 4 个按钮。现在我希望该菜单的背景像动态壁纸一样具有动画效果。

事实上,我只想使用静态背景图像并水平滑动 1-2 个其他图像。我对此进行了一些研究,发现动态壁纸随 API 2.1 一起提供。这将完全符合我的需求,因为应用程序应该与此 API 向下兼容 - 当查看动画时,RenderScript 为。提出了 API 3.1,大多数教程都建立在此之上。

所以现在我只是缺少建议从哪里开始。我感谢各种帮助!

按照建议,我尝试了补间动画 - 我非常关注本教程 http://mobile.tutsplus.com/tutorials/android/android-sdk-creating-a-simple-tween-animation/

在仿真设备中它的工作方式就像一个魅力......但是当我在我的原生 API 2.1 设备上运行它时,没有显示动画......我没有考虑过什么?

【问题讨论】:

  • 要在屏幕上移动一张或两张图片并兼容Android 2,您可以使用Tween Animations。它们不是一流的,但应该适合您的描述。

标签: java android animation view


【解决方案1】:

首先要感谢Class StackerClass Stacker,他给了我使用 Tween Animations 的建议——这真的非常适合我的需求,谢谢! - 不幸的是,动画没有在 API 2.1 设备上显示。

按照这个Tuturial,我像这样设置我的补间动画“clouds_pass.xml” -

<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
android:duration="80000"
android:interpolator="@android:anim/linear_interpolator"
android:fillAfter="true"
>

<translate
    android:fromXDelta="155%p"
    android:toXDelta="-100%p"
    android:repeatCount="infinite"
/>

因为 Activity 像那样调用补间 -

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ImageView clouds = (ImageView)findViewById(R.id.clouds);
    Animation cloudspass = AnimationUtils.loadAnimation(this,R.anim.clouds_pass);
    clouds.startAnimation(cloudspass);

}

我不确定这可能是什么原因.. 但从“clouds_pass.xml”中删除 android:duration 标签并设置持续时间

cloudspass.setDuration(80000);

在加载动画后修复它 - 现在它可以按预期工作到 API 2.0 设备。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-01
    • 1970-01-01
    • 2016-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-01
    相关资源
    最近更新 更多