【问题标题】:Android slide LinearLayout till inner reach bottomAndroid滑动LinearLayout直到内部到达底部
【发布时间】:2016-08-15 17:04:48
【问题描述】:

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

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

slideDown(getContext(), myLayout);

【问题讨论】:

    标签: android animation slide


    【解决方案1】:

    如果我正确理解您的问题,您希望将 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();
    }
    

    【讨论】:

    • 不,在 linearLayout 中,我得到了另一个包含文本的布局。当内部布局底部触摸屏幕底部时,我希望动画停止
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-13
    • 1970-01-01
    • 2017-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多