Search in sources :

Example 81 with ViewPager

use of android.support.v4.view.ViewPager 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 82 with ViewPager

use of android.support.v4.view.ViewPager 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 83 with ViewPager

use of android.support.v4.view.ViewPager 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 84 with ViewPager

use of android.support.v4.view.ViewPager 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 85 with ViewPager

use of android.support.v4.view.ViewPager 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)

Aggregations

ViewPager (android.support.v4.view.ViewPager)246 View (android.view.View)95 PagerAdapter (android.support.v4.view.PagerAdapter)55 Fragment (android.support.v4.app.Fragment)44 TabLayout (android.support.design.widget.TabLayout)37 TextView (android.widget.TextView)35 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)34 Toolbar (android.support.v7.widget.Toolbar)30 Bundle (android.os.Bundle)28 ViewGroup (android.view.ViewGroup)27 FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)21 ImageView (android.widget.ImageView)20 ArrayList (java.util.ArrayList)20 Intent (android.content.Intent)17 ActionBar (android.support.v7.app.ActionBar)15 RecyclerView (android.support.v7.widget.RecyclerView)11 ViewTreeObserver (android.view.ViewTreeObserver)9 AdapterView (android.widget.AdapterView)9 LinearLayout (android.widget.LinearLayout)9 UiController (android.support.test.espresso.UiController)8