我的回收器适配器中有以下代码。向下滚动时,回收器开始滞后,而滑行加载异步图像。如果我移除滑行,那么一切都很完美。有任何想法吗?
@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在绑定时调整大小,则会导致滚动停顿。