Android - Animate a View's topMargin/bottomMargin/etc in LinearLayout or RelativeLayout

后端 未结 5 2173
被撕碎了的回忆
被撕碎了的回忆 2020-12-25 08:24

I am trying to create a menu that slides up from the bottom. It starts with the menu\'s view just visible at the bottom of the screen, and then clicking it causes it to sli

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-25 08:48

    Use the ViewPropertyAnimator:

    if (view.getY() != margin) {
        view.animate().y(margin).setDuration(150).start();
    }
    

提交回复
热议问题