Android: show/hide a view using an animation

后端 未结 9 2067
青春惊慌失措
青春惊慌失措 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:20

    If you only want to animate the height of a view (from say 0 to a certain number) you could implement your own animation:

    final View v = getTheViewToAnimateHere();
    Animation anim=new Animation(){
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            super.applyTransformation(interpolatedTime, t);
            // Do relevant calculations here using the interpolatedTime that runs from 0 to 1
            v.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, (int)(30*interpolatedTime)));
        }};
    anim.setDuration(500);
    v.startAnimation(anim);
    

提交回复
热议问题