Android View Disappearing When Go Outside Of Parent

后端 未结 6 413
甜味超标
甜味超标 2020-12-01 02:38

I have a LinearLayout and ImageView inside this LinearLayout.

There is a translation effect for ImageView.

// v = ImageView    
ObjectAnimator anima         


        
6条回答
  •  無奈伤痛
    2020-12-01 03:13

    Get the view height, then add a percentage of the height to where it will slide to

    public void SlideUp(View view){
         float height = view.getHeight();
    
         TranslateAnimation animate = new TranslateAnimation(0,0,0,0);   
    
         animate.setDuration(500);
         animate.setFillAfter(true);
    
         view.animate().translationY((float)(0-0.62*height)).start(); 
         view.startAnimation(animate);
    }
    

提交回复
热议问题