ExpandAnimationUtil.java 文件源码

java
阅读 24 收藏 0 点赞 0 评论 0

项目:Colombo 作者:
/**
 * Collapse any view with a cool animation
 *
 * @param v
 */
public static void collapse(final View v) {
    final int initialHeight = v.getMeasuredHeight();

    Animation a = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            if (interpolatedTime == 1) {
                v.setVisibility(View.GONE);
            } else {
                v.getLayoutParams().height = initialHeight - (int) (initialHeight * interpolatedTime);
                v.requestLayout();
            }
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    //a.setDuration((int)(initialHeight / v.getContext().getResources().getDisplayMetrics().density));
    a.setDuration(300);
    a.setInterpolator(new FastOutLinearInInterpolator());
    v.startAnimation(a);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号