99import android .view .View ;
1010import android .view .animation .AccelerateInterpolator ;
1111import android .view .animation .DecelerateInterpolator ;
12+ import android .view .animation .OvershootInterpolator ;
1213import android .widget .LinearLayout ;
1314
15+ import net .lucode .hackware .magicindicator .FragmentContainerHelper ;
1416import net .lucode .hackware .magicindicator .MagicIndicator ;
1517import net .lucode .hackware .magicindicator .ViewPagerHelper ;
1618import net .lucode .hackware .magicindicator .buildins .UIUtil ;
@@ -211,6 +213,8 @@ public void onClick(View v) {
211213 @ Override
212214 public IPagerIndicator getIndicator (Context context ) {
213215 LinePagerIndicator linePagerIndicator = new LinePagerIndicator (context );
216+ linePagerIndicator .setMode (LinePagerIndicator .MODE_EXACTLY );
217+ linePagerIndicator .setLineWidth (UIUtil .dip2px (context , 10 ));
214218 linePagerIndicator .setColors (Color .WHITE );
215219 return linePagerIndicator ;
216220 }
@@ -224,6 +228,15 @@ public int getIntrinsicWidth() {
224228 return UIUtil .dip2px (FixedTabExampleActivity .this , 15 );
225229 }
226230 });
227- ViewPagerHelper .bind (magicIndicator , mViewPager );
231+
232+ final FragmentContainerHelper fragmentContainerHelper = new FragmentContainerHelper (magicIndicator );
233+ fragmentContainerHelper .setInterpolator (new OvershootInterpolator (2.0f ));
234+ fragmentContainerHelper .setDuration (300 );
235+ mViewPager .addOnPageChangeListener (new ViewPager .SimpleOnPageChangeListener () {
236+ @ Override
237+ public void onPageSelected (int position ) {
238+ fragmentContainerHelper .handlePageSelected (position );
239+ }
240+ });
228241 }
229242}
0 commit comments