1. 写一个类继承ScrollView,里面有这个一个函数
public void setScroll(int value) { this.scrollTo(0, value); }
2. 定义属性动画
ObjectAnimator mUpAnim = ObjectAnimator.ofInt(this, "scroll", mStart, mEnd); mUpAnim.setDuration(ANIM_DURATION);
ObjectAnimator anim = ObjectAnimator.ofFloat(mSearchView, "scaleX", DOWN, UP); anim.setDuration(ANIM_DURATION); AnimatorSet set = new AnimatorSet(); set.play(anim).with(mUpAnim); set.start();
这里动画会调用的view的setScroll函数,通过scrollTo实现动画,scrollBy类同