How to Scroll ViewPager?

匿名 (未验证) 提交于 2019-12-03 02:38:01

问题:

I am new to Android.How to use ViewPager.scrollBy(int x,int y)? ViewPager.scrollBy(int x,int y) is not updating View

new Handler().post(new Runnable() {                      @Override                     public void run() {                         // TODO Auto-generated method stub                          mainPager.scrollBy(10,0);                      }                 }); 

even this is not updating View. please tell me what is the difference between scrollTo(int x,int y) and scrollBy(int x,int y);

回答1:

From what I understand scrollTo() and scrollBy() are not applicable to ViewPager; they're just methods defined by View that do not apply to ViewPager.

If you're trying to move to a specific page, use setCurrentItem(int item, boolean smoothScroll).



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!