Android: show/hide a view using an animation

后端 未结 9 2300
青春惊慌失措
青春惊慌失措 2021-01-30 00:53

I\'ve been looking through many google results / questions on here to determine how to show/hide a view via a vertical animation, but I can\'t seem to find one that\'s exactly r

9条回答
  •  忘掉有多难
    2021-01-30 01:07

    This can reasonably be achieved in a single line statement in API 12 and above. Below is an example where v is the view you wish to animate;

    v.animate().translationXBy(-1000).start();
    

    This will slide the View in question off to the left by 1000px. To slide the view back onto the UI we can simply do the following.

    v.animate().translationXBy(1000).start();
    

    I hope someone finds this useful.

提交回复
热议问题