How to slide an ImageView from left to right smoothly in Android?

前端 未结 7 1655
小鲜肉
小鲜肉 2021-02-01 21:37

I need to make an ImageView slide from left to right of the screen with a smooth animation (I want the ImageView to be visible during the transition) I

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-01 22:03

    try the code below

    TranslateAnimation animation = new TranslateAnimation(0.0f, 0.0f, 0.0f, 1500.0f); // new TranslateAnimation (float fromXDelta,float toXDelta, float fromYDelta, float toYDelta)
    animation.setDuration(2000); // animation duration
    animation.setRepeatCount(1); // animation repeat count if u repeat only once set to 1 if u don't repeat set to 0
    animation.setFillAfter(false);
    your_view .startAnimation(animation);//your_view for mine is imageView  
    

提交回复
热议问题