Search in sources :

Example 6 with OnTransitionTextListener

use of com.shizhefei.view.indicator.transition.OnTransitionTextListener 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);
}
Also used : DrawableBar(com.shizhefei.view.indicator.slidebar.DrawableBar) 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)

Example 7 with OnTransitionTextListener

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

the class SpringActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_spring);
    ViewPager viewPager = (ViewPager) findViewById(R.id.spring_viewPager);
    Indicator indicator = (ScrollIndicatorView) findViewById(R.id.spring_indicator);
    int selectColor = Color.parseColor("#f8f8f8");
    unSelectColor = Color.parseColor("#010101");
    indicator.setOnTransitionListener(new OnTransitionTextListener().setColor(selectColor, unSelectColor));
    indicator.setScrollBar(new SpringBar(getApplicationContext(), Color.GRAY));
    //        indicator.setScrollBar(new ColorBar(getApplicationContext(), Color.RED, 5));
    viewPager.setOffscreenPageLimit(4);
    indicatorViewPager = new IndicatorViewPager(indicator, viewPager);
    inflate = LayoutInflater.from(getApplicationContext());
    indicatorViewPager.setAdapter(adapter);
    indicatorViewPager.setCurrentItem(5, 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) ScrollIndicatorView(com.shizhefei.view.indicator.ScrollIndicatorView) Indicator(com.shizhefei.view.indicator.Indicator)

Example 8 with OnTransitionTextListener

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

the class FirstLayerFragment method onCreateViewLazy.

@Override
protected void onCreateViewLazy(Bundle savedInstanceState) {
    super.onCreateViewLazy(savedInstanceState);
    setContentView(R.layout.fragment_tabmain);
    Resources res = getResources();
    Bundle bundle = getArguments();
    tabName = bundle.getString(INTENT_STRING_TABNAME);
    index = bundle.getInt(INTENT_INT_INDEX);
    ViewPager viewPager = (ViewPager) findViewById(R.id.fragment_tabmain_viewPager);
    Indicator indicator = (Indicator) findViewById(R.id.fragment_tabmain_indicator);
    switch(index) {
        case 0:
            indicator.setScrollBar(new ColorBar(getApplicationContext(), Color.RED, 5));
            break;
        case 1:
            indicator.setScrollBar(new ColorBar(getApplicationContext(), Color.RED, 0, Gravity.CENTENT_BACKGROUND));
            break;
        case 2:
            indicator.setScrollBar(new ColorBar(getApplicationContext(), Color.RED, 5, Gravity.TOP));
            break;
        case 3:
            indicator.setScrollBar(new LayoutBar(getApplicationContext(), R.layout.layout_slidebar, Gravity.CENTENT_BACKGROUND));
            break;
    }
    float unSelectSize = 16;
    float selectSize = unSelectSize * 1.2f;
    int selectColor = res.getColor(R.color.tab_top_text_2);
    int unSelectColor = res.getColor(R.color.tab_top_text_1);
    indicator.setOnTransitionListener(new OnTransitionTextListener().setColor(selectColor, unSelectColor).setSize(selectSize, unSelectSize));
    viewPager.setOffscreenPageLimit(4);
    indicatorViewPager = new IndicatorViewPager(indicator, viewPager);
    inflate = LayoutInflater.from(getApplicationContext());
    // 注意这里 的FragmentManager 是 getChildFragmentManager(); 因为是在Fragment里面
    // 而在activity里面用FragmentManager 是 getSupportFragmentManager()
    indicatorViewPager.setAdapter(new MyAdapter(getChildFragmentManager()));
    Log.d("cccc", "Fragment 将要创建View " + this);
}
Also used : IndicatorViewPager(com.shizhefei.view.indicator.IndicatorViewPager) Bundle(android.os.Bundle) OnTransitionTextListener(com.shizhefei.view.indicator.transition.OnTransitionTextListener) Resources(android.content.res.Resources) LayoutBar(com.shizhefei.view.indicator.slidebar.LayoutBar) 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)

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