Android - Repeat Scrolling Panoramic Photo Seamlessly Across Background

爷,独闯天下 提交于 2019-12-24 08:38:58

问题


I've been playing around with Java for sometime but I am fairly new to android development and still have lots to learn. I'm building an app for my toddler and would like to scroll a panoramic photo of a sky with clouds across the background of the home screen. I started with ImageView and TranslateAnimation which has the image scroll left to right without repeating. Also, it only shows as much of the image as will fit in the width of the screen. Am I going about this the wrong way? Please send me in the right direction!

Edited to add code: This is in my main activity. animateBackground() is called from onCreate()

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);

This is in the main activity's XML layout file:

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

来源:https://stackoverflow.com/questions/17960701/android-repeat-scrolling-panoramic-photo-seamlessly-across-background

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!