Search in sources :

Example 1 with OnTransitionTextListener

use of com.shizhefei.view.indicator.transition.OnTransitionTextListener in project MVCHelper by LuckyJayce.

the class CoolActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_more_views);
    Indicator indicator = (Indicator) findViewById(R.id.moreviews_indicatorView);
    ViewPager viewPager = (ViewPager) findViewById(R.id.moreviews_viewPager);
    headTextView = (TextView) findViewById(R.id.moreviews_headtext_textView);
    Class[] fragments = { StateHeaderFragment.class, JellyHeaderFragment.class, MaterialHeaderFragment.class, PinContentMaterialHeaderFragment.class };
    indicator.setScrollBar(new ColorBar(this, ContextCompat.getColor(this, R.color.primary), DisplayUtil.dipToPix(this, 3)));
    indicator.setOnTransitionListener(new OnTransitionTextListener().setColor(Color.BLACK, Color.GRAY));
    viewPager.setOffscreenPageLimit(2);
    indicatorViewPager = new IndicatorViewPager(indicator, viewPager);
    indicatorViewPager.setAdapter(pagesAdapter = new PagesAdapter(getSupportFragmentManager(), fragments));
}
Also used : IndicatorViewPager(com.shizhefei.view.indicator.IndicatorViewPager) OnTransitionTextListener(com.shizhefei.view.indicator.transition.OnTransitionTextListener) IndicatorViewPager(com.shizhefei.view.indicator.IndicatorViewPager) ViewPager(android.support.v4.view.ViewPager) Indicator(com.shizhefei.view.indicator.Indicator) ColorBar(com.shizhefei.view.indicator.slidebar.ColorBar) PagesAdapter(com.shizhefei.test.view.adapters.PagesAdapter)

Example 2 with OnTransitionTextListener

use of com.shizhefei.view.indicator.transition.OnTransitionTextListener in project ViewPagerIndicator by LuckyJayce.

the class TabMainActivity method onCreate.

@Override
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    setContentView(R.layout.activity_tabmain);
    SViewPager viewPager = (SViewPager) findViewById(R.id.tabmain_viewPager);
    indicator = (FixedIndicatorView) findViewById(R.id.tabmain_indicator);
    indicator.setOnTransitionListener(new OnTransitionTextListener().setColor(Color.RED, Color.GRAY));
    //这里可以添加一个view,作为centerView,会位于Indicator的tab的中间
    centerView = getLayoutInflater().inflate(R.layout.tab_main_center, indicator, false);
    indicator.setCenterView(centerView);
    centerView.setOnClickListener(onClickListener);
    indicatorViewPager = new IndicatorViewPager(indicator, viewPager);
    indicatorViewPager.setAdapter(new MyAdapter(getSupportFragmentManager()));
    // 禁止viewpager的滑动事件
    viewPager.setCanScroll(false);
    // 设置viewpager保留界面不重新加载的页面数量
    viewPager.setOffscreenPageLimit(4);
}
Also used : IndicatorViewPager(com.shizhefei.view.indicator.IndicatorViewPager) SViewPager(com.shizhefei.view.viewpager.SViewPager) OnTransitionTextListener(com.shizhefei.view.indicator.transition.OnTransitionTextListener)

Example 3 with OnTransitionTextListener

use of com.shizhefei.view.indicator.transition.OnTransitionTextListener in project ViewPagerIndicator by LuckyJayce.

the class YearActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_year);
    ViewPager viewPager = (ViewPager) findViewById(R.id.year_viewPager);
    Indicator indicator = (RecyclerIndicatorView) findViewById(R.id.year_indicator);
    int selectColorId = Color.parseColor("#f8f8f8");
    int unSelectColorId = Color.parseColor("#010101");
    indicator.setOnTransitionListener(new OnTransitionTextListener().setColor(selectColorId, unSelectColorId));
    indicator.setScrollBar(new SpringBar(getApplicationContext(), Color.GRAY));
    viewPager.setOffscreenPageLimit(4);
    indicatorViewPager = new IndicatorViewPager(indicator, viewPager);
    indicatorViewPager.setAdapter(new YearAdapter(1800, 10000000));
    indicatorViewPager.setCurrentItem(2016 - 1800, false);
}
Also used : SpringBar(com.shizhefei.view.indicator.slidebar.SpringBar) IndicatorViewPager(com.shizhefei.view.indicator.IndicatorViewPager) OnTransitionTextListener(com.shizhefei.view.indicator.transition.OnTransitionTextListener) IndicatorViewPager(com.shizhefei.view.indicator.IndicatorViewPager) ViewPager(android.support.v4.view.ViewPager) Indicator(com.shizhefei.view.indicator.Indicator) RecyclerIndicatorView(com.shizhefei.view.indicator.RecyclerIndicatorView)

Example 4 with OnTransitionTextListener

use of com.shizhefei.view.indicator.transition.OnTransitionTextListener in project ViewPagerIndicator by LuckyJayce.

the class SingleTabActivity method set.

private void set(Indicator indicator, int count) {
    indicator.setAdapter(new MyAdapter(count));
    indicator.setScrollBar(new ColorBar(getApplicationContext(), Color.RED, 5));
    float unSelectSize = 16;
    float selectSize = unSelectSize * 1.2f;
    int selectColor = getResources().getColor(R.color.tab_top_text_2);
    int unSelectColor = getResources().getColor(R.color.tab_top_text_1);
    indicator.setOnTransitionListener(new OnTransitionTextListener().setColor(selectColor, unSelectColor).setSize(selectSize, unSelectSize));
    indicator.setCurrentItem(2, true);
}
Also used : OnTransitionTextListener(com.shizhefei.view.indicator.transition.OnTransitionTextListener) ColorBar(com.shizhefei.view.indicator.slidebar.ColorBar)

Example 5 with OnTransitionTextListener

use of com.shizhefei.view.indicator.transition.OnTransitionTextListener in project ViewPagerIndicator by LuckyJayce.

the class MoreTab2Activity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_moretab2);
    ViewPager viewPager = (ViewPager) findViewById(R.id.moretab_viewPager);
    ScrollIndicatorView scrollIndicatorView = (ScrollIndicatorView) findViewById(R.id.moretab_indicator);
    float unSelectSize = 12;
    float selectSize = unSelectSize * 1.3f;
    scrollIndicatorView.setOnTransitionListener(new OnTransitionTextListener().setColor(0xFF2196F3, Color.GRAY).setSize(selectSize, unSelectSize));
    scrollIndicatorView.setScrollBar(new ColorBar(this, 0xFF2196F3, 4));
    viewPager.setOffscreenPageLimit(2);
    indicatorViewPager = new IndicatorViewPager(scrollIndicatorView, viewPager);
    indicatorViewPager.setAdapter(new MyAdapter());
}
Also used : IndicatorViewPager(com.shizhefei.view.indicator.IndicatorViewPager) OnTransitionTextListener(com.shizhefei.view.indicator.transition.OnTransitionTextListener) IndicatorViewPager(com.shizhefei.view.indicator.IndicatorViewPager) ViewPager(android.support.v4.view.ViewPager) ScrollIndicatorView(com.shizhefei.view.indicator.ScrollIndicatorView) ColorBar(com.shizhefei.view.indicator.slidebar.ColorBar)

Aggregations

OnTransitionTextListener (com.shizhefei.view.indicator.transition.OnTransitionTextListener)8 IndicatorViewPager (com.shizhefei.view.indicator.IndicatorViewPager)7 ViewPager (android.support.v4.view.ViewPager)6 Indicator (com.shizhefei.view.indicator.Indicator)4 ColorBar (com.shizhefei.view.indicator.slidebar.ColorBar)4 ScrollIndicatorView (com.shizhefei.view.indicator.ScrollIndicatorView)2 SpringBar (com.shizhefei.view.indicator.slidebar.SpringBar)2 Resources (android.content.res.Resources)1 Bundle (android.os.Bundle)1 PagesAdapter (com.shizhefei.test.view.adapters.PagesAdapter)1 RecyclerIndicatorView (com.shizhefei.view.indicator.RecyclerIndicatorView)1 DrawableBar (com.shizhefei.view.indicator.slidebar.DrawableBar)1 LayoutBar (com.shizhefei.view.indicator.slidebar.LayoutBar)1 SViewPager (com.shizhefei.view.viewpager.SViewPager)1