【Android】 子ViewPager是最后一个滑动父ViewPager

来源:互联网 发布:nike官网抢鞋软件 编辑:程序博客网 时间:2024/06/07 05:55
//重写父ViewPager 的 canScroll方法<pre><code>@Override</code>
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) { if(v != this && v instanceof ViewPager) { int currentItem = ((ViewPager) v).getCurrentItem(); int countItem = ((ViewPager) v).getAdapter().getCount(); if((currentItem==(countItem-1) && dx<0) || (currentItem==0 && dx>0)){ return false; } return true; } return super.canScroll(v, checkV, dx, x, y);}


0 0