hackware1993 / MagicIndicator

A powerful, customizable and extensible ViewPager indicator framework. As the best alternative of ViewPagerIndicator, TabLayout and PagerSlidingTabStrip —— 强大、可定制、易扩展的 ViewPager 指示器框架。是ViewPagerIndicator、TabLayout、PagerSlidingTabStrip的最佳替代品。支持角标,更支持在非ViewPager场景下使用(使用hide()、show()切换Fragment或使用setVisibility切换FrameLayout里的View等),http://www.jianshu.com/p/f3022211821c
9.74k stars 1.55k forks source link

大佬,oppo手机第一次无法正常滑动 #135

Open Cashdispenser opened 6 years ago

Cashdispenser commented 6 years ago

在已关闭的问题里面有,但是那个是2016年的了,现在这个问题怎么处理呢,用的是CommonNavigator,目前只发现oppo手机是这样的 CommonNavigator commonNavigator = new CommonNavigator(mActivity); commonNavigator.setAdapter(new CommonNavigatorAdapter() { @Override public int getCount() { return null == custom ? 0 : custom.size(); }

        @Override
        public IPagerTitleView getTitleView(Context context, final int i) {
            SimplePagerTitleView simplePagerTitleView = new ScaleTransitionPagerTitleView(context);
            simplePagerTitleView.setText(custom.get(i).getName());
            simplePagerTitleView.setTextSize(20);
            simplePagerTitleView.setNormalColor(Color.parseColor("#999999"));
            simplePagerTitleView.setSelectedColor(Color.parseColor("#333333"));
            if (simplePagerTitleView.isSelected()) {
                simplePagerTitleView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
            } else {
                simplePagerTitleView.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
            }
            simplePagerTitleView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    pos = i;
                    vp_home.setCurrentItem(i);
                    gridViewAdapter.setSelectPos(i);
                    gridViewAdapter.notifyDataSetChanged();
                    NormalUtils.baiduStatistics(mActivity, custom.get(i).getEventid(), "首页-" + custom.get(i).getName());

                }
            });
            return simplePagerTitleView;
        }

        @Override
        public IPagerIndicator getIndicator(Context context) {
            LinePagerIndicator indicator = new LinePagerIndicator(context);
            indicator.setMode(LinePagerIndicator.MODE_EXACTLY);
            indicator.setLineHeight(UIUtil.dip2px(context, 0));
            indicator.setLineWidth(UIUtil.dip2px(context, 0));
            indicator.setStartInterpolator(new AccelerateInterpolator());
            indicator.setEndInterpolator(new DecelerateInterpolator(2.0f));
            indicator.setColors(Color.parseColor("#ff4849"));
            return indicator;
        }
    });
    magic_indicator.setNavigator(commonNavigator);
    ViewPagerHelper.bind(magic_indicator, vp_home);
hackware1993 commented 6 years ago

你先确保 ViewPager 是不是能滑动,以及 ViewPager 的滑动回调是不是出错了,MI 是无状态的,滑不滑、滑多少完全依赖外面的回调。