由左到右的背景图片的运动背景图片、左到右

2023-09-05 03:56:55 作者:从不善良喜欢就抢

我工作的应用程序。在登录界面有一个bcakground图像。我想移动从左到右此背景下image.how我可以做到这一点?

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.?

一个样本codeI有使用,但是这将移动图像和左布局balnk。我不希望它。

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 :

在检查该应用登录界面设备。登录界面有背景的图像。从这个图片左右移动。我怎样才能做到这一点process.please帮助我。

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.

推荐答案

您可以尝试使用的矩阵。

设置ImageView的以矩阵的scaleType。

set the scaleType of the ImageView to matrix.

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

再转换成了ImageView的使用有点向右每毫秒的矩阵。

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