问题
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