Android - 无缝跨越背景重复滚动全景照片

时间:2013-07-31 02:39:42

标签: android imageview translate-animation

我一直在玩Java,但我对Android开发还很新,还有很多需要学习的东西。我正在为我的孩子建立一个应用程序,并希望在主屏幕的背景上滚动一张天空的全景照片。 我开始使用ImageView和TranslateAnimation,它从左到右滚动图像而不重复。此外,它仅显示适合屏幕宽度的图像。我是以错误的方式来做这件事的吗?请把我送往正确的方向!

已编辑添加代码 这是我的主要活动。从onCreate()

调用animateBackground()
public void animateBackground() {
    ImageView myImage = (ImageView) findViewById(R.id.background);
    Animation animation = new TranslateAnimation(0, 4800, 0, 0);
    animation.setDuration(10000);
    animation.setFillAfter(true);
    myImage.startAnimation(animation);

这是在主活动的XML布局文件中:

 <ImageView
    android:id="@+id/background"
    android:layout_height="match_parent"
    android:layout_width="wrap_content"
    android:src="@drawable/sky_background"
    android:scaleType="center">
</ImageView>

0 个答案:

没有答案