CardSlider
CardSlider copied to clipboard
java.lang.IllegalStateException: Pages must fill the whole ViewPager2 (use match_parent)
Hello, Same problem. My Code;
java.lang.IllegalStateException: Pages must fill the whole ViewPager2 (use match_parent) at com.github.islamkhsh.viewpager2.ViewPager2$2.onChildViewAttachedToWindow(ViewPager2.java:205)
@CeRBeR666 solution
is to make item_view
of adapter to has match_parent
for both width, height
this worked with me.
I still had the same problem, because I was using the ViewBinding. If you go with raw implementation like
public class BannerHolder extends RecyclerView.ViewHolder{ public BannerHolder(@NonNull @NotNull View itemView) { super(itemView); } }
It will work.
However if you try to use View Binding like this in adapter:
public BannerHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { return new BannerHolder(ItemBannerBinding.inflate(LayoutInflater.from(parent.getContext()))); }
This won't work. Hope you understand the change, if you still got the error like me, and got no where to go!
i will close the issue as it did not occur after make height and width as match parent.
@MahmoudMabrok the library is really great. Thank you all the contributors.
Can you please at least do additional logs for this issue? Because if we use viewBinding for the item_view, and the item_view's LayoutParams is of course both match_parent, this issue still occurs. Do you have any thoughts? Or at least do some logs, where we find the view class that was received by the renderer? And log the found width and height?
Thanks again.
it does not occur to me, also I do not have access to the code to try, sorry for this. I have faced this issue for a long time and solved it at that time. so I closed this issue.