Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Background image move from left to right

I am working on app. in which login screen have a bcakground image. I want to move left to right this background image.how can i do this.?

A sample code i have using but this will move the image and left the layout balnk. i dont 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 as like this application screen :

check this application login screen in device. login screen have an image in background. and this image move from left to right. How can i achieve this process.please assist me.

enter image description here

like image 261
Amardeepvijay Avatar asked Nov 01 '22 13:11

Amardeepvijay


1 Answers

You can try to use matrix.

set the scaleType of the ImageView to matrix.

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

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

Matrix matrix = new Matrix();
matrix.postTranslate(x, y);
img_animation.setImageMatrix(matrix);
like image 143
Happy Cupz Cupz Avatar answered Nov 08 '22 03:11

Happy Cupz Cupz