开发者

Move a little image over the screen

I would like to know how I can move a small image on the screen. The user clicks for instance a small 开发者_开发百科block and after that I would like to slide it over the screen.


You just need to create a TranslationAnimation and apply it. Should look something like this:

mButton.setOnClickListener(new View.OnClickListener()
{
    @Override
    public void onClick(View view)
    {
        TranslateAnimation slide = new TranslateAnimation(0.0f, 1.0f, 0.0f, 1.0f);
        view.startAnimation(slide);
    }
});

Here is a link to the info on TranslateAnimation

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜