动态改变控件的高

/**
     * 动态改变view的高
     * @param view 要修改的控件
     * @param from 从多少
     * @param to 到多少
     */
    public static void change(final View view,float from, float to ){
        ValueAnimator animator = ValueAnimator.ofFloat(from, to);
        animator.setDuration(1000);
        animator.setInterpolator(new LinearInterpolator());
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float value = (float) animation.getAnimatedValue();
                LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.
                        LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
                params.height = (int) value;
                view.setLayoutParams(params);
            }
        });
        animator.start();
    }

你可能感兴趣的:(动态改变控件的高)