HorizontalScrollView实现先左滑动后右滑动动画

时间:2022-12-18 07:50:56
 @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); HorizontalScrollView hsTabs = (HorizontalScrollView ) findViewById(R.id.hsTabs); new Handler().postDelayed(new Runnable() { @Override
public void run() { ObjectAnimator oa = ObjectAnimator.ofInt(hsTabs, "scrollX", 0, 150);
oa.setDuration(500); final ObjectAnimator oa2 = ObjectAnimator
.ofInt(hsTabs, "scrollX", 150, 0);
oa2.setDuration(500); oa.addListener(new AnimatorListener() { @Override
public void onAnimationStart(Animator arg0) { } @Override
public void onAnimationRepeat(Animator arg0) { } @Override
public void onAnimationEnd(Animator arg0) {
oa2.start(); } @Override
public void onAnimationCancel(Animator arg0) { }
}); oa.start(); }
}, 1000);
}