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
精彩评论