Background image moves from left to right

I am working on an application. in which the login screen has a bcakground image. I want to move this background image from left to right. How can i do this?

Sample code that I use, but this will move the image and leave the balnk layout. I do not want it.

ImageView img_animation = (ImageView) findViewById(R.id.img_animation); TranslateAnimation animation = new TranslateAnimation(0.0f, 400.0f, 0.0f, 0.0f); animation.setDuration(5000); animation.setRepeatCount(5); animation.setRepeatMode(2); animation.setFillAfter(true); img_animation.startAnimation(animation); 

I just want to implement the same application screen:

Check this application device login screen. The login screen has an image in the background. and this image moves from left to right. How can I achieve this process.please help me.

enter image description here

+5
source share
1 answer

You can try using matrix .

set the scale type of the image to the matrix.

 <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="matrix" /> 

then translate the matrix used by ImageView a little to the right every milliseconds.

 Matrix matrix = new Matrix(); matrix.postTranslate(x, y); img_animation.setImageMatrix(matrix); 
+2
source

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


All Articles