Android RecyclerView在滚动时滞后



我的回收器适配器中有以下代码。向下滚动时,回收器开始滞后,而滑动加载异步图像。如果我去掉滑翔,那就完美了。有什么想法吗?

@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
Customer customer= customerList.get(position);
((CustomerViewHolder)holder).binding.setCustomer (customer);
RequestOptions ro = new RequestOptions();
ro.diskCacheStrategy(DiskCacheStrategy.NONE);
ro.skipMemoryCache(true);
ro.centerCrop();
Glide.with(mCtx)
.applyDefaultRequestOptions(ro)
.load(customer.getImagePath())
.into(((CustomerViewHolder)holder).binding.imageView);
((CustomerViewHolder)holder).binding.executePendingBindings();
}

在加载图像之前,请确保为ViewHolder设置固定的高度。如果在绑定时调整ViewHolder的大小,则会导致滚动断断续续。

最新更新