1 @Override 2 protected void onCreate(Bundle savedInstanceState) { 3 super.onCreate(savedInstanceState); 4 setContentView(R.layout.activity_main); 5 6 HorizontalScrollView hsTabs = (HorizontalScrollView ) findViewById(R.id.hsTabs); 7 8 new Handler().postDelayed(new Runnable() { 9 10 @Override11 public void run() {12 13 14 15 ObjectAnimator oa = ObjectAnimator.ofInt(hsTabs, "scrollX", 0, 150);16 oa.setDuration(500);17 18 19 final ObjectAnimator oa2 = ObjectAnimator20 .ofInt(hsTabs, "scrollX", 150, 0);21 oa2.setDuration(500);22 23 oa.addListener(new AnimatorListener() {24 25 @Override26 public void onAnimationStart(Animator arg0) {27 28 }29 30 @Override31 public void onAnimationRepeat(Animator arg0) {32 33 }34 35 @Override36 public void onAnimationEnd(Animator arg0) {37 oa2.start();38 39 }40 41 @Override42 public void onAnimationCancel(Animator arg0) {43 44 }45 });46 47 oa.start();48 49 }50 }, 1000);51 }