Android中的全景背景动画

N J*_*Jay 5 animation android

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);
Run Code Online (Sandbox Code Playgroud)

但这似乎不起作用......任何解决方案?

我目前正在将图像设置为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" />
Run Code Online (Sandbox Code Playgroud)

如何将图像设置为从左侧开始的屏幕,如下所示,以帮助全景动画效果: 在此输入图像描述

N J*_*Jay 3

在所有手机系列上高效且快速的最佳解决方案实际上是仅对云进行动画处理,同时保持背景静态。您还可以向速度添加一些变量,这将为云的速度添加一些随机化,这样您就不会得到单调循环。

实施细节和解决方案取自此答案