Azoft / CarouselLayoutManager

Android Carousel LayoutManager for RecyclerView
Apache License 2.0
2.56k stars 367 forks source link

setMaxVisibleItems seems to have no effect #76

Closed fernnando closed 3 years ago

fernnando commented 6 years ago

I'm facing an issue with setting max visible items to carousel, setting the max number to layout manager seems to have no effect at all, it keeps showing 2 items on both sides.

CarouselLayoutManager layoutManager = new CarouselLayoutManager(CarouselLayoutManager.HORIZONTAL, true); 
layoutManager.setMaxVisibleItems(1);
layoutManager.setPostLayoutListener(new CarouselZoomPostLayoutListener());

binding.rvCarousel.setLayoutManager(layoutManager);
binding.rvCarousel.setHasFixedSize(true);

Am i doing anything wrong here?

mig35 commented 6 years ago

Hi @fernnando!

Thanks for your report. I do not see any problem. As it is said in the docs: "Basically during scrolling there can be more visible items (+1 item on each side), but in idle state this is the only reached maximum". So if you see 2 items on each side in the idle state (while you set your maximum to 1), then this is a bug. Otherwise it is not.

If you still think that this is a bug, then post a gif with bug, your device info and layouts (recyclerview and adapter) that you are using.

Thanks.

fernnando commented 6 years ago

Thanks for answering @mig35 ;)

Actually its showing 2 items on both sides, even in iddle state. Last night i downloaded your sample project and there setMaxVisibleItems is working fine, probably there's something in my project im messing up. I'll check better my code, if the problem is related to any bug i'll post it here.

Thanks!

teshlya commented 6 years ago

fernnando, I have the same problem. How did you decide it?

jpvs0101 commented 6 years ago

Sure it has. To check that just put a container as Match Parent in landscape mode with max items 2.

Now change it to 6. You can see difference! On 13-Aug-2018 11:13 pm, "teshlya" notifications@github.com wrote:

fernnando, I have the same problem. How did you decide it?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Azoft/CarouselLayoutManager/issues/76#issuecomment-412603056, or mute the thread https://github.com/notifications/unsubscribe-auth/AkhD6qTuju30QNLwIkYTaCjhvrI4uOy-ks5uQbqogaJpZM4UbCkf .

Gadiq commented 5 years ago

On idle experiencing same issue with maxVal = 1 it shows 2 items left and right.

Morteza-Rastgoo commented 5 years ago

@mig35 in the sample if you remove the background color and scroll the items, you'll see there is 2 items loading even if you put layoutManager.setMaxVisibleItems(1);

Screen Shot 2019-07-30 at 4 20 54 PM