android - Android中的全景背景动画

标签 android animation

Panoramicbackground

我有一个全景背景作为天空,我想从左向右移动然后从右向左移动以模拟移动的云动画作为屏幕背景。

这应该无限期地重复,然后在进入最右边然后返回最左边..

我尝试了以下方法:

  Animation left = AnimationUtils.loadAnimation(MainActivity.this, com.icare.kids.R.anim.view_transition_out_right);
  left.setRepeatCount(Animation.INFINITE);
  left.setRepeatMode(Animation.REVERSE);
  left.setDuration(3000);

  findViewById(id.cloud).startAnimation(left);

但这似乎不起作用……有什么解决办法吗?

我目前正在将图像设置为 ImageView,如下所示:

<ImageView
    android:id="@+id/cloud"
    android:layout_width="3000dip"
    android:layout_height="wrap_content"
    android:layout_below="@id/topbar"
    android:scaleType="matrix"
    android:src="@drawable/bgpan" />

我怎样才能将图像设置为从最左边开始显示在屏幕上,如下所示,以帮助实现全景动画效果: enter image description here

最佳答案

在所有手机范围内高效且快速的最佳解决方案是实际上只为云设置动画,同时保持背景静态。 您还可以为速度添加一些变量,从而为云的速度添加一些随机化,这样您就不会得到单调循环。

实现细节和解决方案取自 this answer

关于android - Android中的全景背景动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17156940/

相关文章:

android - 在android中从一年中的周数获取日期

android - 在 DialogFragment 中禁用正/负按钮

html - 我添加了一个 CSS 动画,但它不起作用,但一切看起来都很好

php - 我的网站有一个 php 标题,里面有一个 css 动画,但我不想在某些页面上出现动画

javascript - 在javascript中延迟函数的更好方法?

android - 如何制作 android imageview 方形?

java - 在 Android 中创建波形 UI

android - 无法在 Android Studio 中运行示例 Project Tango 应用程序

animation - 横向iPad上带有键盘的模态视图 Controller 在关闭时更改位置

ios - UITableView 崩溃,因为 "Attempt to create two animations for cell"(iOS 7)