2016-04-22 63 views
0

如何将面板滑动到底部直到面板内部布局达到屏幕底部。然后停止动画。所有面板布局都是动态高度。不得使用静态值。 我使用:Android滑动LinearLayout直到内部达到底部

public void slideDown(Context context, LinearLayout ln){ 
     Animation slide_down = AnimationUtils.loadAnimation(context, R.anim.slide_down); 
     ln.startAnimation(slide_down); 
    } 

slideDown(getContext(), myLayout); 

回答

0

如果我正确理解你的问题,你要滑动的LinearLayout到屏幕的底部,并停止动画时lineaLayout底部“触摸“屏幕的底部。下面是我如何做到这一点:

public void slideDown (View movableView,View rootView){ 
    //rootView is the Layout placed as root in your xml 
    float screenBottom = rootView.getBottom()/2; //real bottom of the screen 
    float viewHeight = movableView.getHeight(); 
    movableView.animate().translationYBy(screenBottom - viewHeight).setDuration(1000).start(); 
} 
+0

不,在linearLayout中,我得到了另一个包含文本的布局。当内部布局底部触摸屏幕底部时,我希望动画停止 – TeodorKolev