Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Panoramic Background animation in Android

Panoramicbackground

I have a panoramic background as a sky that i want to move from left to right and then from right to left to simulate a moving clouds animation as a screen background .

This should repeat indefinitely and after goin to the right most then return back to the left most..

I have tried the following:

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

But this does not seem to work... any solution for that ?

I am currently setting the image to an ImageView as follows:

<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" />

how can i set the image to the screen to start from the left most like this below, so to help in the panoramic animation effect: enter image description here

like image 523
N Jay Avatar asked Oct 22 '22 07:10

N Jay


1 Answers

The best solution that is efficient and fast on all phone ranges was to actually only animate the clouds while keeping the background static. you can also add some variable to the speed that would add some randomization to the speed of the clouds so you don't get a monotonic looping.

Implementation details and solution was taken from this answer

like image 175
N Jay Avatar answered Oct 27 '22 20:10

N Jay