Open TellH opened 8 years ago
private Animation.AnimationListener mRefreshListener = new Animation.AnimationListener() {
...
@Override
public void onAnimationEnd(Animation animation) {
isProgressEnable = true;
if (mRefreshing) {
...
} else {
mHeadViewContainer.setVisibility(View.GONE);
if (mScale) {
setAnimationProgress(0);
} else {
/*
setTargetOffsetTopAndBottom(mOriginalOffsetTop
- mCurrentTargetOffsetTop, true);
*/
final int from = mTarget.getTop();
final int to = 0;
ValueAnimator animator = ValueAnimator.ofFloat(0,1).setDuration(200);
animator.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float value = (float) animation.getAnimatedValue();
float step = (to - from) * value + from;
int top = mTarget.getTop();
setTargetOffsetTopAndBottom((int) (step - top),true);
}
});
animator.start();
}
}
....
}
};
这样应该就可以了
我本来想重构一下代码,在mTarget和mHeaderViewContainer使用属性动画,让两者在手指松开时同时回滚到顶部,但这样做并不行,请问这是为什么?