Horizontal Recyclerview: setting custom item width is creating issues

53 Views Asked by At

Dont know whether there's an issue with my code or the recyclerview itself, but whenever I'm trying to populate a new list to the recyclerview, it auto scrolls itself to the top of the index. This does not happen when I set the items' width to MATCH PARENT, only if I am setting a custom width to the itemviews, this strange bug happens.I also tried using notifyItemRangeChanged or notifyItemChanged, but unfortunately nothing seems to work.

val layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
recyclerViewSubscriptions.layoutManager = layoutManager
recyclerViewSubscriptions.adapter = subscriptionAdapter
subscriptionAdapter?.setData(subscriptionList, true, null, false)

Adapter setData code:

fun setData(
    users: MutableList<SubscribtionListItem>?,
    hideButtons: Boolean,
    activeSubscriptionType: Int?,
    isPendingRequest: Boolean,
    isPlanReplaced: Boolean = false,
    standardPlanDuration: Int = 0
) {
    this.subscribtionListItem = users
    notifyDataSetChanged()
}
0

There are 0 best solutions below