use of net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator in project MagicIndicator by hackware1993.
the class FixedTabExampleActivity method initMagicIndicator4.
private void initMagicIndicator4() {
MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator4);
CommonNavigator commonNavigator = new CommonNavigator(this);
commonNavigator.setAdapter(new CommonNavigatorAdapter() {
@Override
public int getCount() {
return mDataList.size();
}
@Override
public IPagerTitleView getTitleView(Context context, final int index) {
SimplePagerTitleView simplePagerTitleView = new ColorTransitionPagerTitleView(context);
simplePagerTitleView.setNormalColor(Color.GRAY);
simplePagerTitleView.setSelectedColor(Color.WHITE);
simplePagerTitleView.setText(mDataList.get(index));
simplePagerTitleView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mViewPager.setCurrentItem(index);
}
});
return simplePagerTitleView;
}
@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;
}
});
magicIndicator.setNavigator(commonNavigator);
// must after setNavigator
LinearLayout titleContainer = commonNavigator.getTitleContainer();
titleContainer.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
titleContainer.setDividerDrawable(new ColorDrawable() {
@Override
public int getIntrinsicWidth() {
return UIUtil.dip2px(FixedTabExampleActivity.this, 15);
}
});
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);
}
});
}
use of net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator in project MagicIndicator by hackware1993.
the class FixedTabExampleActivity method initMagicIndicator1.
private void initMagicIndicator1() {
MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator1);
CommonNavigator commonNavigator = new CommonNavigator(this);
commonNavigator.setAdapter(new CommonNavigatorAdapter() {
@Override
public int getCount() {
return mDataList == null ? 0 : mDataList.size();
}
@Override
public IPagerTitleView getTitleView(Context context, final int index) {
SimplePagerTitleView simplePagerTitleView = new ColorTransitionPagerTitleView(context);
simplePagerTitleView.setText(mDataList.get(index));
simplePagerTitleView.setNormalColor(Color.parseColor("#88ffffff"));
simplePagerTitleView.setSelectedColor(Color.WHITE);
simplePagerTitleView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mViewPager.setCurrentItem(index);
}
});
return simplePagerTitleView;
}
@Override
public IPagerIndicator getIndicator(Context context) {
LinePagerIndicator indicator = new LinePagerIndicator(context);
indicator.setColors(Color.parseColor("#40c4ff"));
return indicator;
}
});
magicIndicator.setNavigator(commonNavigator);
// must after setNavigator
LinearLayout titleContainer = commonNavigator.getTitleContainer();
titleContainer.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
titleContainer.setDividerPadding(UIUtil.dip2px(this, 15));
titleContainer.setDividerDrawable(getResources().getDrawable(R.drawable.simple_splitter));
ViewPagerHelper.bind(magicIndicator, mViewPager);
}
use of net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator in project MagicIndicator by hackware1993.
the class FragmentContainerExampleActivity method initMagicIndicator1.
private void initMagicIndicator1() {
MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator1);
magicIndicator.setBackgroundResource(R.drawable.round_indicator_bg);
CommonNavigator commonNavigator = new CommonNavigator(this);
commonNavigator.setAdapter(new CommonNavigatorAdapter() {
@Override
public int getCount() {
return CHANNELS.length;
}
@Override
public IPagerTitleView getTitleView(Context context, final int index) {
ClipPagerTitleView clipPagerTitleView = new ClipPagerTitleView(context);
clipPagerTitleView.setText(CHANNELS[index]);
clipPagerTitleView.setTextColor(Color.parseColor("#e94220"));
clipPagerTitleView.setClipColor(Color.WHITE);
clipPagerTitleView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mFragmentContainerHelper.handlePageSelected(index);
switchPages(index);
}
});
return clipPagerTitleView;
}
@Override
public IPagerIndicator getIndicator(Context context) {
LinePagerIndicator indicator = new LinePagerIndicator(context);
float navigatorHeight = context.getResources().getDimension(R.dimen.common_navigator_height);
float borderWidth = UIUtil.dip2px(context, 1);
float lineHeight = navigatorHeight - 2 * borderWidth;
indicator.setLineHeight(lineHeight);
indicator.setRoundRadius(lineHeight / 2);
indicator.setYOffset(borderWidth);
indicator.setColors(Color.parseColor("#bc2a2a"));
return indicator;
}
});
magicIndicator.setNavigator(commonNavigator);
mFragmentContainerHelper.attachMagicIndicator(magicIndicator);
}
use of net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator in project MagicIndicator by hackware1993.
the class ScrollableTabExampleActivity method initMagicIndicator2.
private void initMagicIndicator2() {
MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator2);
magicIndicator.setBackgroundColor(Color.parseColor("#00c853"));
CommonNavigator commonNavigator = new CommonNavigator(this);
commonNavigator.setScrollPivotX(0.25f);
commonNavigator.setAdapter(new CommonNavigatorAdapter() {
@Override
public int getCount() {
return mDataList == null ? 0 : mDataList.size();
}
@Override
public IPagerTitleView getTitleView(Context context, final int index) {
SimplePagerTitleView simplePagerTitleView = new SimplePagerTitleView(context);
simplePagerTitleView.setText(mDataList.get(index));
simplePagerTitleView.setNormalColor(Color.parseColor("#c8e6c9"));
simplePagerTitleView.setSelectedColor(Color.WHITE);
simplePagerTitleView.setTextSize(12);
simplePagerTitleView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mViewPager.setCurrentItem(index);
}
});
return simplePagerTitleView;
}
@Override
public IPagerIndicator getIndicator(Context context) {
LinePagerIndicator indicator = new LinePagerIndicator(context);
indicator.setMode(LinePagerIndicator.MODE_EXACTLY);
indicator.setYOffset(UIUtil.dip2px(context, 3));
indicator.setColors(Color.parseColor("#ffffff"));
return indicator;
}
});
magicIndicator.setNavigator(commonNavigator);
ViewPagerHelper.bind(magicIndicator, mViewPager);
}
use of net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator in project MagicIndicator by hackware1993.
the class ScrollableTabExampleActivity method initMagicIndicator7.
private void initMagicIndicator7() {
MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator7);
magicIndicator.setBackgroundColor(Color.parseColor("#fafafa"));
CommonNavigator commonNavigator7 = new CommonNavigator(this);
commonNavigator7.setScrollPivotX(0.65f);
commonNavigator7.setAdapter(new CommonNavigatorAdapter() {
@Override
public int getCount() {
return mDataList == null ? 0 : mDataList.size();
}
@Override
public IPagerTitleView getTitleView(Context context, final int index) {
SimplePagerTitleView simplePagerTitleView = new ColorFlipPagerTitleView(context);
simplePagerTitleView.setText(mDataList.get(index));
simplePagerTitleView.setNormalColor(Color.parseColor("#9e9e9e"));
simplePagerTitleView.setSelectedColor(Color.parseColor("#00c853"));
simplePagerTitleView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mViewPager.setCurrentItem(index);
}
});
return simplePagerTitleView;
}
@Override
public IPagerIndicator getIndicator(Context context) {
LinePagerIndicator indicator = new LinePagerIndicator(context);
indicator.setMode(LinePagerIndicator.MODE_EXACTLY);
indicator.setLineHeight(UIUtil.dip2px(context, 6));
indicator.setLineWidth(UIUtil.dip2px(context, 10));
indicator.setRoundRadius(UIUtil.dip2px(context, 3));
indicator.setStartInterpolator(new AccelerateInterpolator());
indicator.setEndInterpolator(new DecelerateInterpolator(2.0f));
indicator.setColors(Color.parseColor("#00c853"));
return indicator;
}
});
magicIndicator.setNavigator(commonNavigator7);
ViewPagerHelper.bind(magicIndicator, mViewPager);
}
Aggregations