int sw = DisplayUtils.getScreenWidth(mContext);
int h = DisplayUtils.dipToPx(mContext, 40);
if (animator == null) {
animator = android.animation.ValueAnimator.ofFloat(100f, 0f, 0f, 0f, 0f, 0f, 0f, 100f);
animator.setDuration(1300);
animator.setInterpolator(new LinearInterpolator());
animator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
ViewUtils.setVisibility(mTvUpdateNotice, View.GONE);
}
@Override
public void onAnimationCancel(Animator animation) {
ViewUtils.setVisibility(mTvUpdateNotice, View.GONE);
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float value = (Float) animation.getAnimatedValue();
float x = value / 100;
LogUtils.e("long", "value = " + value + " , x = " + x);
LinearLayout.LayoutParams p = (LinearLayout.LayoutParams) mTvUpdateNotice.getLayoutParams();
p.topMargin = (int) (-1 * h * x);
p.width = (int) (sw * ( 1 - x));
mTvUpdateNotice.setLayoutParams(p);
mTvUpdateNotice.setAlpha((int) (1 - x));
LogUtils.e("long", "topMargin = " + p.topMargin + ", width = " + p.width);
// mTvUpdateNotice.requestLayout();
}
});
}
animator.start();