Skip to content

Commit

Permalink
增加弹性效果的演示
Browse files Browse the repository at this point in the history
  • Loading branch information
hackware1993 committed Nov 26, 2016
1 parent 06dd559 commit c94f547
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.OvershootInterpolator;
import android.widget.LinearLayout;

import net.lucode.hackware.magicindicator.FragmentContainerHelper;
import net.lucode.hackware.magicindicator.MagicIndicator;
import net.lucode.hackware.magicindicator.ViewPagerHelper;
import net.lucode.hackware.magicindicator.buildins.UIUtil;
Expand Down Expand Up @@ -211,6 +213,8 @@ public void onClick(View v) {
@Override
public IPagerIndicator getIndicator(Context context) {
LinePagerIndicator linePagerIndicator = new LinePagerIndicator(context);
linePagerIndicator.setMode(LinePagerIndicator.MODE_EXACTLY);
linePagerIndicator.setLineWidth(UIUtil.dip2px(context, 10));
linePagerIndicator.setColors(Color.WHITE);
return linePagerIndicator;
}
Expand All @@ -224,6 +228,15 @@ public int getIntrinsicWidth() {
return UIUtil.dip2px(FixedTabExampleActivity.this, 15);
}
});
ViewPagerHelper.bind(magicIndicator, mViewPager);

final FragmentContainerHelper fragmentContainerHelper = new FragmentContainerHelper(magicIndicator);
fragmentContainerHelper.setInterpolator(new OvershootInterpolator(2.0f));
fragmentContainerHelper.setDuration(300);
mViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
fragmentContainerHelper.handlePageSelected(position);
}
});
}
}

0 comments on commit c94f547

Please sign in to comment.