如何将视图放置在其他动画下方?

时间:2018-10-05 02:57:36

标签: android animation view

我今天开始在android上学习动画,动画结束后我无法定位视图。

应用启动时,它会在屏幕中央显示一个搜索EditText,当您搜索内容时,该EditText应该使用下面的代码滑到顶部

public void slideToTop(View view){
    view.animate()
            .translationY((-parent.getHeight()/2) + view.getHeight())
            .setInterpolator(new AccelerateInterpolator())
            .setDuration(500)
            .setListener(new Animator.AnimatorListener() {
                             @Override
                             public void onAnimationStart(Animator animator) {

                             }

                             @Override
                             public void onAnimationEnd(Animator animator) {
                                layoutContent.setVisibility(View.VISIBLE);
                             }

                             @Override
                             public void onAnimationCancel(Animator animator) {

                             }

                             @Override
                             public void onAnimationRepeat(Animator animator) {

                             }
                         });
                    fadeOutAndHideImage(logo);
}

如何在现在位于布局顶部的EditText下显示结果?
    我尝试使用RelativeLayout中的layout_below属性,该属性设置动画结束时的可见性,但似乎位置是在动画之前计算的

1 个答案:

答案 0 :(得分:1)

动画结束时,您必须使用programatically将视图(-parent.getHeight()/2) + view.getHeight()的位置设置为Layout Params,这可能有助于您解决问题。