use of com.shizhefei.view.indicator.slidebar.DrawableBar in project ViewPagerIndicator by LuckyJayce.
the class MoreTabActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_moretab);
splitAutotoggleButton = (ToggleButton) findViewById(R.id.toggleButton1);
pinnedToggleButton = (ToggleButton) findViewById(R.id.toggleButton2);
ViewPager viewPager = (ViewPager) findViewById(R.id.moretab_viewPager);
scrollIndicatorView = (ScrollIndicatorView) findViewById(R.id.moretab_indicator);
scrollIndicatorView.setBackgroundColor(Color.RED);
scrollIndicatorView.setScrollBar(new DrawableBar(this, R.drawable.round_border_white_selector, Gravity.CENTENT_BACKGROUND) {
@Override
public int getHeight(int tabHeight) {
return tabHeight - dipToPix(12);
}
@Override
public int getWidth(int tabWidth) {
return tabWidth - dipToPix(12);
}
});
unSelectTextColor = Color.WHITE;
// 设置滚动监听
scrollIndicatorView.setOnTransitionListener(new OnTransitionTextListener().setColor(Color.RED, unSelectTextColor));
viewPager.setOffscreenPageLimit(2);
indicatorViewPager = new IndicatorViewPager(scrollIndicatorView, viewPager);
inflate = LayoutInflater.from(getApplicationContext());
indicatorViewPager.setAdapter(new MyAdapter(getSupportFragmentManager()));
// 默认true ,自动布局
splitAutotoggleButton.setChecked(scrollIndicatorView.isSplitAuto());
splitAutotoggleButton.setOnCheckedChangeListener(onCheckedChangeListener);
pinnedToggleButton.setOnCheckedChangeListener(onCheckedChangeListener);
}
Aggregations