Open GaneshB-Extentia opened 9 years ago
This worked quite nicely for me: https://github.com/surfstudio/InfinitePageIndicator
@joshma91 The link provided above worked but the animation of circlepageindicator from last item to first item not good? because it go to empty spot then come to first spot. Any idea how we can fix the animation from last to first of circlepageindicator with infiniteViewpager?
@vsay01 I'm sorry, I'm a bit removed from the project where I used this and don't have the source code anymore. Did you do all of the things this page recommends doing? https://github.com/surfstudio/InfinitePageIndicator/blob/master/README.md
@joshma91 Yes, I was be able to set the circlepagindicator with the infiniteviewpager. But in the demo, they recommended the animation should be disabled. From the demo:
// Because animation between circles now looks ugly, we should disable it
mPageIndicator.setSnap(true);
When I enable the animation it works fine first to second to the last but the animation from last to first and first to last the animation not good because selected circle move to the empty spot (virtual spot) before move to first or last.
Any idea how can we improve it? Thank
@vsay01 Found my code - here's my implementation. You can see there's a couple tweaks in here which I think I needed to add to get it to work. Hope this helps
pagerView = (InfiniteViewPager) activity.findViewById(R.id.pager);
pageIndicator = (CirclePageIndicator) activity.findViewById(R.id.line_indicator);
pageIndicator.setSnap(true);
currentPosition = 0;
ArrayList<ListItem> listItem = getListItems();
//add the first item again as the last, to create the wrap effect
listItem.add(listItem .get(0));
//insert a copy of the last item as the new first item, so we can scroll backwards
listItem.add(0, listItem.get(listItem.size() - 1));
listAdapter = new ListAdapter(activity, listItem);
pagerAdapter = new InfinitePagerAdapter(listAdapter );
pagerAdapter.setOneItemMode();
pagerView.setAdapter(pagerAdapter);
pagerView.setCurrentItem(currentPosition);
pageIndicator.setCurrentItem(currentPosition);
pagerView.invalidate();
pagerView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent touchevent) {
return false;
}
});
@joshma91 Thank I followed the code I got an error ViewPager has not been bound it seems like you didnt bound the view pager to pageindicator?
Plus when you setSnap(true) it will disable the animation, but I would like to keep the animation of the circlePageindicator.
@vsay01 woops. turns out I set the viewpager in another method. Put this pageIndicator.setViewPager(pagerView); right before pagerView.setCurrentItem(currentPosition)
I'm not sure about the setSnap. Just try true/false and see what works for you
@joshma91 I tried your code
@vsay01 I'm sorry, I'm out of ideas on how to help you now. That was all I had for my code... Good luck with this, I hope you figure it out soon.
@joshma91 Thank :+1:
doesnt work for me, it freezes then crashes later
@monchiez13 For me too - it crashes if I use TabLayout with InfiniteViewPager !! Seems this lib is not intended to work with the TabLayouts or page indicators !!
Any fix would be appreciated !! :)
CirclePageIndicator (com.viewpagerindicator.CirclePageIndicator) is not working with InfiniteViewPager.