如何在屏幕上移动一个绘制 [英] How to move a drawable across the screen

查看:111
本文介绍了如何在屏幕上移动一个绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在四处寻找一个答案,这并没有一直在寻找多。我希望这不是很难回答。我想要做的就是有一个可绘制或图像从左向右移动,或在我的主菜单画面反之亦然。举例来说,如果我有一个云的照片,有没有办法把它启动关闭屏幕和移动从左至右跨越它的权利和循环回到起点。云的照片将保持不变,它只是在屏幕上移动。感谢您的任何帮助,你可以给我。

I have been looking around for an answer to this and have not been finding much. I hope this is not hard to answer. What I want to do is have a drawable or an image move left to right or vise versa across my main menu screen. For example, if I had a picture of a cloud is there a way to have it start off the screen and move from left to right across it and the loop back to the beginning. The picture of the cloud would stay the same and it would just move across the screen. Thanks for any help you can give me.

推荐答案

使用翻译框架,以实现这一目标,该工程为:

Use Translation framework to achieve this, this works as:

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

所以,你需要写你的code在x轴方向移动视图,如下:

So you need to write your code for moving view in x-axis direction, as follows:

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

这篇关于如何在屏幕上移动一个绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆