简体   繁体   中英

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 . The method you could use is the onPageScrolled method.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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