I have an EpoxyRecyclerView with several horizontal Carousels. These carousels contain items of varying heights. The problem here is when I scroll the carousel the items that are longer are sometimes truncated as depicted in the image below. How can I get around this problem? I have tried to replace Carousel with an EpoxyRecyclerView but the behavior is still the same.
(Image credits to SO post)
EpoxyRecyclerView inherits from AndroidX RecyclerView v1.2.1
I have searched all over SO for solutions and just found one that has worked but doesn't seem to be an efficient one.
LinearLayoutManager layoutManager = new LinearLayoutManager(context,
LinearLayoutManager.HORIZONTAL, false);
layoutManager.setMeasurementCacheEnabled(false);
YourRecyclerView.setLayoutManager(layoutManager);
YourRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
layoutManager.requestLayout();
}
});