use of net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView in project MagicIndicator by hackware1993.
the class ScrollableTabExampleActivity method initMagicIndicator6.
private void initMagicIndicator6() {
MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator6);
magicIndicator.setBackgroundColor(Color.WHITE);
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 ScaleTransitionPagerTitleView(context);
simplePagerTitleView.setText(mDataList.get(index));
simplePagerTitleView.setTextSize(18);
simplePagerTitleView.setNormalColor(Color.GRAY);
simplePagerTitleView.setSelectedColor(Color.BLACK);
simplePagerTitleView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mViewPager.setCurrentItem(index);
}
});
return simplePagerTitleView;
}
@Override
public IPagerIndicator getIndicator(Context context) {
BezierPagerIndicator indicator = new BezierPagerIndicator(context);
indicator.setColors(Color.parseColor("#ff4a42"), Color.parseColor("#fcde64"), Color.parseColor("#73e8f4"), Color.parseColor("#76b0ff"), Color.parseColor("#c683fe"));
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 initMagicIndicator3.
private void initMagicIndicator3() {
MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator3);
magicIndicator.setBackgroundColor(Color.BLACK);
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_WRAP_CONTENT);
linePagerIndicator.setColors(Color.WHITE);
return linePagerIndicator;
}
});
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 initMagicIndicator8.
private void initMagicIndicator8() {
MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator8);
magicIndicator.setBackgroundColor(Color.WHITE);
CommonNavigator commonNavigator = new CommonNavigator(this);
commonNavigator.setScrollPivotX(0.35f);
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) {
WrapPagerIndicator indicator = new WrapPagerIndicator(context);
indicator.setFillColor(Color.parseColor("#ebe4e3"));
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 BadgeTabExampleActivity 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) {
final BadgePagerTitleView badgePagerTitleView = new BadgePagerTitleView(context);
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);
// cancel badge when click tab
badgePagerTitleView.setBadgeView(null);
}
});
badgePagerTitleView.setInnerPagerTitleView(simplePagerTitleView);
// setup badge
if (index != 2) {
TextView badgeTextView = (TextView) LayoutInflater.from(context).inflate(R.layout.simple_count_badge_layout, null);
badgeTextView.setText("" + (index + 1));
badgePagerTitleView.setBadgeView(badgeTextView);
} else {
ImageView badgeImageView = (ImageView) LayoutInflater.from(context).inflate(R.layout.simple_red_dot_badge_layout, null);
badgePagerTitleView.setBadgeView(badgeImageView);
}
// set badge position
if (index == 0) {
badgePagerTitleView.setXBadgeRule(new BadgeRule(BadgeAnchor.CONTENT_LEFT, -UIUtil.dip2px(context, 6)));
badgePagerTitleView.setYBadgeRule(new BadgeRule(BadgeAnchor.CONTENT_TOP, 0));
} else if (index == 1) {
badgePagerTitleView.setXBadgeRule(new BadgeRule(BadgeAnchor.CONTENT_RIGHT, -UIUtil.dip2px(context, 6)));
badgePagerTitleView.setYBadgeRule(new BadgeRule(BadgeAnchor.CONTENT_TOP, 0));
} else if (index == 2) {
badgePagerTitleView.setXBadgeRule(new BadgeRule(BadgeAnchor.CENTER_X, -UIUtil.dip2px(context, 3)));
badgePagerTitleView.setYBadgeRule(new BadgeRule(BadgeAnchor.CONTENT_BOTTOM, UIUtil.dip2px(context, 2)));
}
// don't cancel badge when tab selected
badgePagerTitleView.setAutoCancelBadge(false);
return badgePagerTitleView;
}
@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);
}
Aggregations