Moving an image through a linearlayout

后端 未结 4 1614
一生所求
一生所求 2021-01-27 02:48

I\'m developing an Android 2.2 application.

I want to move an image from left side of the screen to the right side of the screen.

How can I do that? I\'ve read t

4条回答
  •  灰色年华
    2021-01-27 03:23

    Please take a look at the Animation class, specifically the Tween Animation, more specifically the Translate element. Create an animation file in your project then apply this animation to your image. For example, this animation would move an object from the center of the screen to the right side.

    
    
    
    

    EDIT: To apply this animation to a Button, a TextView, an ImageView, etc.

    ImageView imageView = (ImageView) findViewById(R.id.myImageView);
    Animation exitAnimation = AnimationUtils.loadAnimation(this, R.anim.exit_animation);
    imageView.startAnimation(exitAnimation);
    

提交回复
热议问题