Comments (11)
可以修改LoopViewPager ,先添加
private boolean isCanScroll = true;
public boolean isCanScroll() {
return isCanScroll;
}
public void setCanScroll(boolean isCanScroll) {
this.isCanScroll = isCanScroll;
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (isCanScroll)
return super.onTouchEvent(ev);
else
return false;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (isCanScroll)
return super.onInterceptTouchEvent(ev);
else
return false;
}
然后在setAdapter方法中修改
@Override
public void setAdapter(PagerAdapter adapter) {
mAdapter = new LoopPagerAdapterWrapper(adapter);
mAdapter.setBoundaryCaching(mBoundaryCaching);
super.setAdapter(mAdapter);
//fix blinking issue when item is scrolling from first to last,cause ViewPager instance item left current right at least,see more at setOffScreenLimit()
setCurrentItem(mAdapter.getRealCount(), false);
//个数小于2的时候不滚动
if (mAdapter.getRealCount() < 2) {
setCanScroll(false);
}
}
from android-convenientbanner.
我有提供stopTurning()方法出来的,而且你也可以判断数据只有一条就不startTurning就不会自己开启翻页。
from android-convenientbanner.
我知道stopTurning方法。我的意思是只有一条数据的时候,不仅仅是停止自动翻页,连手动翻页的操作都想禁止。
from android-convenientbanner.
hey,根据你的要求,我增加了一个接口,convenientBanner.setManualPageable(false);设置不能手动影响,请更新1.0.6版本吧
from android-convenientbanner.
Nice!
from android-convenientbanner.
manualPageable为false的时候,imageView的click事件会被吃掉吧。。。我是这样改的
if (!manualPageable && ev.getAction == MotionEvent.ACTION_MOVE) {
return true;
}
return super.dispatchTouchEvent(ev);
不过这样有个缺点是 down-move-up 会被当成click事件。
最好是能禁止viewPager的无限循环。
from android-convenientbanner.
除了你这个方案,我也没有其他更好的idea了。
from android-convenientbanner.
adapter返回真实的数量,而不是count+2,并且onPageScrollStateChanged中不做任何事情。
不过这样改动就有点大了,可能和你最初的需求不同了。等我的PM发现上面那个缺点时我再自己fork一份改改吧:)
from android-convenientbanner.
楼上这样也不是最好的办法,甚至连点击事件都被覆盖了
from android-convenientbanner.
adapter.addHeader(convenientBanner) 把控件放到刷新的listview上,左右滑动的时候上下偏移就会有冲突。
from android-convenientbanner.
如果数据设置两条以上,
例如3条或者4条,上来就直接向左边滑动,控件会被清一下,
您的这个adapter处理我不太看得懂,
下面留一个gif,
http://wy.21bit.cn/test/sa.gif
from android-convenientbanner.
Related Issues (20)
- banner放在recyclerview里,重新创建的时候会回弹 HOT 1
- 关于修改页面数据的接口
- 在kotlin下使用的一个问题 HOT 5
- ConvenientBanner height=wrap_content 问题 HOT 1
- 怎么没有release版本呢
- 画廊效果能支持吗
- Bug
- 开源性不高。很多属性都要自己手动改源码才行。不想youth那个banner拓展性强。 HOT 2
- 怎么没发现如图片上的动效呢? 应该如何设置?
- ConstraintLayout 下面嵌套不显示 HOT 4
- notifyDataSetChanged() 方法无效
- 按住最后一个条目拖动过半然后松开手自动滚动到第一个,第一个条目首先会超出banner边界然后回弹到正常位置 HOT 1
- Banner
- 更新之后Transformer 干掉了? HOT 3
- convenientBanner提供的setFirstItemPos问题
- 这个组件能使用在React-Native项目中吗?
- v2.0.5 banner 作为recyclerview 的头布局,点击无效,在自动翻页的时候,可以点击
- 可以用于商业用途吗? HOT 2
- 发现的问题以及修改建议
- 切换到最后一张图时,后一张图片显示出问题。 HOT 6
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 android-convenientbanner.