简体   繁体   English

在 android 中同时滚动两个不同的浏览器

[英]Scroll two dirreferent viewpagers same time in android

i need scroll my view pagers same time when scroll one view pager.滚动一个视图寻呼机时,我需要同时滚动我的视图寻呼机。 also those viewpagers has different item width.那些浏览器也有不同的项目宽度。 bottom view pager is full width content and top view pager smaller than bottom view pager item.底部视图寻呼机是全宽内容,顶部视图寻呼机小于底部视图寻呼机项目。

You can use ViewPager.onPageChangeListener .您可以使用ViewPager.onPageChangeListener The method you could use is the onPageScrolled method.您可以使用的方法是onPageScrolled方法。

public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    //Move other viewpager by the same positionOffset
}

You can set this listener for both ViewPagers, and by changing one, you can make the same change on the other as well.您可以为两个 ViewPagers 设置此侦听器,并且通过更改其中一个,您也可以对另一个进行相同的更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM