Giter Club home page Giter Club logo

Comments (17)

hackware1993 avatar hackware1993 commented on July 30, 2024 1

我在真机上跑了跑,没发现不能滚动的问题。CommonNavigator只是一个HorizontalScrollView + LinearLayout,没有任何理由不滚动啊。对了,你那个RecyclerView的item动画不错!

from magicindicator.

452MJ avatar 452MJ commented on July 30, 2024

一直会跳会第一个Fragment。只有点击到其他Fragment时才能正常滑动

from magicindicator.

452MJ avatar 452MJ commented on July 30, 2024

可以下载调试看看

from magicindicator.

452MJ avatar 452MJ commented on July 30, 2024

我把自己的 CommonPagerTitleView自定义布局代码替换了Demo中ScrollableTabExampleActivity的initMagicIndicator2()中SimplePagerTitleView。发现刚进去也不能正常滑动。CommonPagerTitleView自定义布局中有个bug吧?

from magicindicator.

452MJ avatar 452MJ commented on July 30, 2024

出现Bug的gif图,比较直观。
bug

from magicindicator.

452MJ avatar 452MJ commented on July 30, 2024

navigator.setSkimOver(true);
加上这句就好了=。=这行代码是什么含义

from magicindicator.

452MJ avatar 452MJ commented on July 30, 2024

navigator.setSkimOver(true);
只有用于ClipPagerTitleView才有作用。
CommonPagerTitleView还是不行。

from magicindicator.

hackware1993 avatar hackware1993 commented on July 30, 2024

你是在虚拟机上不能滑动么?以真机为准,我马上下载你的跑马跑一跑

from magicindicator.

452MJ avatar 452MJ commented on July 30, 2024
public IPagerTitleView getTitleView(final Context context, final int index) {
                ClipPagerTitleView titleView = new ClipPagerTitleView(context);
                titleView.setText(titleList.get(index));
                titleView.setBackground(context.getResources().getDrawable(R.drawable.ripple_tab));
                titleView.setTextSize(SizeUtils.sp2px(context, 12));
                titleView.setTextColor(context.getResources().getColor(R.color.color_secondary_text));
                titleView.setClipColor(context.getResources().getColor(R.color.color_primary));
                titleView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        viewPager.setCurrentItem(index);
                    }
                });
                return titleView;

//                CommonPagerTitleView titleView = new CommonPagerTitleView(context);
//                titleView.setContentView(R.layout.item_explore_tab_indicator_layout);//加载自定义布局作为Tab
//
//                final TextView tab_textview = (TextView) titleView.findViewById(R.id.tab_text);
//                titleView.setOnPagerTitleChangeListener(new CommonPagerTitleView.OnPagerTitleChangeListener() {
//                    @Override
//                    public void onSelected(int i, int i1) {
//                        tab_textview.setText(tnameArray[i]);
//                        tab_textview.setTextColor(context.getResources().getColor(R.color.color_primary));
//                    }
//
//                    @Override
//                    public void onDeselected(int i, int i1) {
//                        tab_textview.setText(tnameArray[i]);
//                        tab_textview.setTextColor(context.getResources().getColor(R.color.color_secondary_text));
//                    }
//
//                    @Override
//                    public void onLeave(int i, int i1, float v, boolean b) {
//
//                    }
//
//                    @Override
//                    public void onEnter(int i, int i1, float v, boolean b) {
//
//                    }
//                });
//                titleView.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View v) {
//                        viewPager.setCurrentItem(index);
//                    }
//                });
//                return titleView;
            }

@hackware1993 可以正常滚动是因为我把CommonPagerTitleView 暂时先注释掉,换成ClipPagerTitleView了,ClipPagerTitleView是正常的,你试下去掉注释换成CommonPagerTitleView 。我的OPPO真机还是不行,就跟那gif里效果一样,要点击选择其他页面后才可以正常滑动。其他PagerTitleView我还没尝试,暂时只有CommonPagerTitleView 发现这问题。

from magicindicator.

452MJ avatar 452MJ commented on July 30, 2024

因为我是想给Tab添加个5.0系统的点击波纹效果,所以才想到用自定义布局。现在折中的处理方法就是ClipPagerTitleView.setBackground(context.getResources().getDrawable(R.drawable.ripple_tab)),自己定义一个ripple.xml来设置背景。

from magicindicator.

hackware1993 avatar hackware1993 commented on July 30, 2024

@452MJ 还是不行么

from magicindicator.

452MJ avatar 452MJ commented on July 30, 2024

@hackware1993 是的。CommonPagerTitleView 依旧不行。你把CommonPagerTitleView 注释去掉尝试下。

from magicindicator.

452MJ avatar 452MJ commented on July 30, 2024

大概知道原因了。如上面CommonPagerTitleView的监听中,onSelected&OnDeselected中setText,貌似会一直使焦点重置在第一个Tab,我把setText提到监听外,就不会有上述的情况。

之前也有使用过在监听中设置setText,不过Tab的数目比较少且固定3-4个,所以一直没有滑动的问题。

from magicindicator.

CK875430315 avatar CK875430315 commented on July 30, 2024
   ClipPagerTitleView titleView = new ClipPagerTitleView(context);
            titleView.setText(titleList.get(index));  这里调用了setText()方法后相应的父类里onSelected 和onDeselected方法里如果也调用了setText方法就会出现这个问题 好像

from magicindicator.

CodeK1988 avatar CodeK1988 commented on July 30, 2024

一样的问题 建议修复 @hackware1993 多谢~

from magicindicator.

CodeK1988 avatar CodeK1988 commented on July 30, 2024

原因 onDeselected onSelected 多次回调
解决方式 自己维护 list集合加状态

var curItem: Int = -1 // -1 未选中 0 onDeselected 1 onSelected

建议修复~ 多谢 @hackware1993

from magicindicator.

zzzsssbo avatar zzzsssbo commented on July 30, 2024

怎么解决,我也遇到了这个问题

from magicindicator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.