How to move the selection around the screen

I searched for the answer to this question and did not find much. I hope this is easy to answer. What I want to do is draw or move the image left or right on the main menu screen. For example, if I had a photo of a cloud, there is a way for it to start from the screen and move from left to right along it, and the cycle will return to the beginning. The image of the cloud would remain the same and it would simply move around the screen. Thanks for any help you can give me.

+1
source share
1 answer

To achieve this, use the Translation Framework interface, which works like:

TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta) 

So, you need to write your code to move in the x axis direction, as shown below:

  mAnimation = new TranslateAnimation(0, 599, 0, 0); mAnimation.setDuration(10000); mAnimation.setFillAfter(true); mAnimation.setRepeatCount(-1); mAnimation.setRepeatMode(Animation.REVERSE); view.setAnimation(mAnimation); 
+4
source

Source: https://habr.com/ru/post/1395899/


All Articles