Comments (17)
我在真机上跑了跑,没发现不能滚动的问题。CommonNavigator只是一个HorizontalScrollView + LinearLayout,没有任何理由不滚动啊。对了,你那个RecyclerView的item动画不错!
from magicindicator.
一直会跳会第一个Fragment。只有点击到其他Fragment时才能正常滑动
from magicindicator.
可以下载调试看看
from magicindicator.
我把自己的 CommonPagerTitleView自定义布局代码替换了Demo中ScrollableTabExampleActivity的initMagicIndicator2()中SimplePagerTitleView。发现刚进去也不能正常滑动。CommonPagerTitleView自定义布局中有个bug吧?
from magicindicator.
from magicindicator.
navigator.setSkimOver(true);
加上这句就好了=。=这行代码是什么含义
from magicindicator.
navigator.setSkimOver(true);
只有用于ClipPagerTitleView才有作用。
CommonPagerTitleView还是不行。
from magicindicator.
你是在虚拟机上不能滑动么?以真机为准,我马上下载你的跑马跑一跑
from magicindicator.
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.
因为我是想给Tab添加个5.0系统的点击波纹效果,所以才想到用自定义布局。现在折中的处理方法就是ClipPagerTitleView.setBackground(context.getResources().getDrawable(R.drawable.ripple_tab)),自己定义一个ripple.xml来设置背景。
from magicindicator.
@452MJ 还是不行么
from magicindicator.
@hackware1993 是的。CommonPagerTitleView 依旧不行。你把CommonPagerTitleView 注释去掉尝试下。
from magicindicator.
大概知道原因了。如上面CommonPagerTitleView的监听中,onSelected&OnDeselected中setText,貌似会一直使焦点重置在第一个Tab,我把setText提到监听外,就不会有上述的情况。
之前也有使用过在监听中设置setText,不过Tab的数目比较少且固定3-4个,所以一直没有滑动的问题。
from magicindicator.
ClipPagerTitleView titleView = new ClipPagerTitleView(context);
titleView.setText(titleList.get(index)); 这里调用了setText()方法后相应的父类里onSelected 和onDeselected方法里如果也调用了setText方法就会出现这个问题 好像
from magicindicator.
一样的问题 建议修复 @hackware1993 多谢~
from magicindicator.
原因 onDeselected onSelected 多次回调
解决方式 自己维护 list集合加状态
var curItem: Int = -1 // -1 未选中 0 onDeselected 1 onSelected
建议修复~ 多谢 @hackware1993
from magicindicator.
怎么解决,我也遇到了这个问题
from magicindicator.
Related Issues (20)
- 怎么监听他的滑动事件
- Failed to resolve: com.github.hackware1993:MagicIndicator:1.6.0
- 作者大佬能否增加个 indicator 的局部刷新的方法呀 HOT 1
- 关于小米11无限onLayout解决方案
- 垂直方向能否增加支持? 我尝试改了下,问题太多了, HOT 1
- 1.7.0 MagicIndicator 与viewpager2联用不能点击 HOT 7
- ViewPagerHelper.bind(magicIndicator, mViewPager); 不支持传ViewPager2 ? HOT 1
- 希望提供选中字体和未选中字体大小设置方法,不使用缩放方式 HOT 2
- 不支持talkback
- QQ群搜索不到 HOT 1
- 好家伙。人人都是产品经理是吧。issues应该给你们改成提需求区 HOT 1
- 能支持下 viewpage2? HOT 3
- 不支持setCurrentItem(index, false)? HOT 7
- 卧槽。大佬居然回来了 HOT 2
- work with ViewPager时 commonPagerTitleView.onPagerTitleChangeListener无效
- Title 不能识别换行符 \n 啊啊啊
- 怎么设置无限滑动呢 HOT 2
- 多加点其他动画效果吧 这些都过时了 可以看看爱奇艺其他社交 酷炫指示器动画
- 如何设置TitleView的背景色,直接设置后,指示器的颜色会被遮住
- 页面初次加载后,onSelected会触发多次的问题请问如何解决 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magicindicator.