Search in sources :

Example 1 with ColorBar

use of com.shizhefei.view.indicator.slidebar.ColorBar 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 ColorBar

use of com.shizhefei.view.indicator.slidebar.ColorBar 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 3 with ColorBar

use of com.shizhefei.view.indicator.slidebar.ColorBar 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)

Example 4 with ColorBar

use of com.shizhefei.view.indicator.slidebar.ColorBar 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)

Example 5 with ColorBar

use of com.shizhefei.view.indicator.slidebar.ColorBar in project ViewPagerIndicator by LuckyJayce.

the class BannerActivity method onCreate.

@Override
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    setContentView(R.layout.activity_banner);
    //ViewPager,Indicator
    ViewPager viewPager = (ViewPager) findViewById(R.id.banner_viewPager);
    Indicator indicator = (Indicator) findViewById(R.id.banner_indicator);
    indicator.setScrollBar(new ColorBar(getApplicationContext(), Color.WHITE, 0, ScrollBar.Gravity.CENTENT_BACKGROUND));
    viewPager.setOffscreenPageLimit(2);
    bannerComponent = new BannerComponent(indicator, viewPager, false);
    bannerComponent.setAdapter(adapter);
    findViewById(R.id.button3).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            images = new int[] {};
            adapter.notifyDataSetChanged();
        }
    });
    findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            images = new int[] { R.drawable.p2 };
            adapter.notifyDataSetChanged();
        }
    });
    findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            images = new int[] { R.drawable.p1, R.drawable.p2, R.drawable.p3, R.drawable.p4 };
            adapter.notifyDataSetChanged();
        }
    });
    //默认就是800毫秒,设置单页滑动效果的时间
    //        bannerComponent.setScrollDuration(800);
    //设置播放间隔时间,默认情况是3000毫秒
    bannerComponent.setAutoPlayTime(2500);
}
Also used : IndicatorViewPager(com.shizhefei.view.indicator.IndicatorViewPager) ViewPager(android.support.v4.view.ViewPager) BannerComponent(com.shizhefei.view.indicator.BannerComponent) ImageView(android.widget.ImageView) View(android.view.View) Indicator(com.shizhefei.view.indicator.Indicator) ColorBar(com.shizhefei.view.indicator.slidebar.ColorBar)

Aggregations

ColorBar (com.shizhefei.view.indicator.slidebar.ColorBar)5 ViewPager (android.support.v4.view.ViewPager)4 IndicatorViewPager (com.shizhefei.view.indicator.IndicatorViewPager)4 OnTransitionTextListener (com.shizhefei.view.indicator.transition.OnTransitionTextListener)4 Indicator (com.shizhefei.view.indicator.Indicator)3 Resources (android.content.res.Resources)1 Bundle (android.os.Bundle)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 PagesAdapter (com.shizhefei.test.view.adapters.PagesAdapter)1 BannerComponent (com.shizhefei.view.indicator.BannerComponent)1 ScrollIndicatorView (com.shizhefei.view.indicator.ScrollIndicatorView)1 LayoutBar (com.shizhefei.view.indicator.slidebar.LayoutBar)1