开发者

Move a little image over the screen

开发者 https://www.devze.com 2022-12-22 23:11 出处:网络
I would like to know how I can move a small image on the screen. The user clicks for instancea small 开发者_开发百科block and after that I would like to slide it over the screen.You just need to creat

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

精彩评论

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