Ama*_*jay 5 android android-animation
我正在开发应用程序.其中登录屏幕有bcakground图像.我想从左到右移动这个背景图片.我可以这样做吗?
我使用的示例代码,但这将移动图像并离开布局balnk.我不想要它.
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);
Run Code Online (Sandbox Code Playgroud)
我只想像这个应用程序屏幕一样实现:
检查设备中的此应用程序登录屏幕.登录屏幕在背景中有一个图像.这个图像从左向右移动.我怎样才能实现这个过程.请帮助我.

小智 2
您可以尝试使用矩阵。
将 ImageView 的scaleType 设置为matrix。
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="matrix" />
Run Code Online (Sandbox Code Playgroud)
然后每毫秒将 ImageView 使用的矩阵向右移动一点。
Matrix matrix = new Matrix();
matrix.postTranslate(x, y);
img_animation.setImageMatrix(matrix);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1250 次 |
| 最近记录: |