use of net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView in project MagicIndicator by hackware1993.
the class BadgeTabExampleActivity 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) {
BadgePagerTitleView badgePagerTitleView = new BadgePagerTitleView(context);
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);
}
});
badgePagerTitleView.setInnerPagerTitleView(simplePagerTitleView);
return badgePagerTitleView;
}
@Override
public IPagerIndicator getIndicator(Context context) {
LinePagerIndicator linePagerIndicator = new LinePagerIndicator(context);
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(BadgeTabExampleActivity.this, 15);
}
});
ViewPagerHelper.bind(magicIndicator, mViewPager);
}
use of net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView in project MagicIndicator by hackware1993.
the class BadgeTabExampleActivity method initMagicIndicator2.
private void initMagicIndicator2() {
MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator2);
magicIndicator.setBackgroundColor(Color.WHITE);
CommonNavigator commonNavigator = new CommonNavigator(this);
commonNavigator.setAdjustMode(true);
commonNavigator.setAdapter(new CommonNavigatorAdapter() {
@Override
public int getCount() {
return mDataList == null ? 0 : mDataList.size();
}
@Override
public IPagerTitleView getTitleView(Context context, final int index) {
BadgePagerTitleView badgePagerTitleView = new BadgePagerTitleView(context);
SimplePagerTitleView simplePagerTitleView = new ScaleTransitionPagerTitleView(context);
simplePagerTitleView.setText(mDataList.get(index));
simplePagerTitleView.setTextSize(18);
simplePagerTitleView.setNormalColor(Color.parseColor("#616161"));
simplePagerTitleView.setSelectedColor(Color.parseColor("#f57c00"));
simplePagerTitleView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mViewPager.setCurrentItem(index);
}
});
badgePagerTitleView.setInnerPagerTitleView(simplePagerTitleView);
// setup badge
if (index == 1) {
ImageView badgeImageView = (ImageView) LayoutInflater.from(context).inflate(R.layout.simple_red_dot_badge_layout, null);
badgePagerTitleView.setBadgeView(badgeImageView);
badgePagerTitleView.setXBadgeRule(new BadgeRule(BadgeAnchor.CENTER_X, -UIUtil.dip2px(context, 3)));
badgePagerTitleView.setYBadgeRule(new BadgeRule(BadgeAnchor.CONTENT_BOTTOM, UIUtil.dip2px(context, 2)));
}
// cancel badge when click tab, default true
badgePagerTitleView.setAutoCancelBadge(true);
return badgePagerTitleView;
}
@Override
public IPagerIndicator getIndicator(Context context) {
LinePagerIndicator indicator = new LinePagerIndicator(context);
indicator.setStartInterpolator(new AccelerateInterpolator());
indicator.setEndInterpolator(new DecelerateInterpolator(1.6f));
indicator.setYOffset(UIUtil.dip2px(context, 39));
indicator.setLineHeight(UIUtil.dip2px(context, 1));
indicator.setColors(Color.parseColor("#f57c00"));
return indicator;
}
@Override
public float getTitleWeight(Context context, int index) {
if (index == 0) {
return 2.0f;
} else if (index == 1) {
return 1.2f;
} else {
return 1.0f;
}
}
});
magicIndicator.setNavigator(commonNavigator);
ViewPagerHelper.bind(magicIndicator, mViewPager);
}
use of net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView in project MagicIndicator by hackware1993.
the class FixedTabExampleActivity method initMagicIndicator2.
private void initMagicIndicator2() {
MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator2);
magicIndicator.setBackgroundColor(Color.WHITE);
CommonNavigator commonNavigator = new CommonNavigator(this);
commonNavigator.setAdjustMode(true);
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 ScaleTransitionPagerTitleView(context);
simplePagerTitleView.setText(mDataList.get(index));
simplePagerTitleView.setTextSize(18);
simplePagerTitleView.setNormalColor(Color.parseColor("#616161"));
simplePagerTitleView.setSelectedColor(Color.parseColor("#f57c00"));
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.setStartInterpolator(new AccelerateInterpolator());
indicator.setEndInterpolator(new DecelerateInterpolator(1.6f));
indicator.setYOffset(UIUtil.dip2px(context, 39));
indicator.setLineHeight(UIUtil.dip2px(context, 1));
indicator.setColors(Color.parseColor("#f57c00"));
return indicator;
}
@Override
public float getTitleWeight(Context context, int index) {
if (index == 0) {
return 2.0f;
} else if (index == 1) {
return 1.2f;
} else {
return 1.0f;
}
}
});
magicIndicator.setNavigator(commonNavigator);
ViewPagerHelper.bind(magicIndicator, mViewPager);
}
use of net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView in project MagicIndicator by hackware1993.
the class ScrollableTabExampleActivity method initMagicIndicator5.
private void initMagicIndicator5() {
MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator5);
magicIndicator.setBackgroundColor(Color.WHITE);
CommonNavigator commonNavigator = new CommonNavigator(this);
commonNavigator.setScrollPivotX(0.8f);
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 ScaleTransitionPagerTitleView(context);
simplePagerTitleView.setText(mDataList.get(index));
simplePagerTitleView.setTextSize(18);
simplePagerTitleView.setNormalColor(Color.parseColor("#616161"));
simplePagerTitleView.setSelectedColor(Color.parseColor("#f57c00"));
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.setStartInterpolator(new AccelerateInterpolator());
indicator.setEndInterpolator(new DecelerateInterpolator(1.6f));
indicator.setYOffset(UIUtil.dip2px(context, 39));
indicator.setLineHeight(UIUtil.dip2px(context, 1));
indicator.setColors(Color.parseColor("#f57c00"));
return indicator;
}
});
magicIndicator.setNavigator(commonNavigator);
ViewPagerHelper.bind(magicIndicator, mViewPager);
}
use of net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView in project MagicIndicator by hackware1993.
the class ScrollableTabExampleActivity method initMagicIndicator9.
private void initMagicIndicator9() {
MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator9);
magicIndicator.setBackgroundColor(Color.WHITE);
CommonNavigator commonNavigator = new CommonNavigator(this);
commonNavigator.setScrollPivotX(0.15f);
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("#333333"));
simplePagerTitleView.setSelectedColor(Color.parseColor("#e94220"));
simplePagerTitleView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mViewPager.setCurrentItem(index);
}
});
return simplePagerTitleView;
}
@Override
public IPagerIndicator getIndicator(Context context) {
TriangularPagerIndicator indicator = new TriangularPagerIndicator(context);
indicator.setLineColor(Color.parseColor("#e94220"));
return indicator;
}
});
magicIndicator.setNavigator(commonNavigator);
ViewPagerHelper.bind(magicIndicator, mViewPager);
}
Aggregations