简体   繁体   English

使用滑行加载图像时,如何从 Recyclerview 中的 imageview 清除焦点?

[英]How to clear focus from imageview in Recyclerview when loading image with glide?

I found an error (more likely bug) when load image with glide on Recyclerview.在 Recyclerview 上使用滑行加载图像时,我发现了一个错误(更可能是错误)。 The problem is that when I load image from URL into an imageview on recyclerview item, imageview seem to have focus on it.问题是,当我将 URL 中的图像加载到recyclerview项目上的imageview中时, imageview似乎专注于它。 Here is how it looks like: imageview gained focus after load image with glide下面是它的样子: imageview 在使用滑行加载图像后获得焦点

This causes recyclerview scrolls by itself (I cant post a video).这会导致recyclerview自行滚动(我无法发布视频)。 Is there any idea how to solve this?有没有办法解决这个问题? Thank you and sorry for my English.谢谢你,对不起我的英语。

Try this:尝试这个:

recyclerview.setFocusable(false); recyclerview.setFocusable(false);

try setting the isFocusable to false forcefully while loading the image using Glide.在使用 Glide 加载图像时,尝试将isFocusable强制设置为 false。 it's just a try maybe it works for you.这只是一个尝试,也许它适合你。

That is because RecyclerView ALWAYS set:那是因为 RecyclerView 总是设置:

setFocusableInTouchMode(true);

so if you apply those attribute in your XML for a RecyclerView因此,如果您在 XML 中将这些属性应用于 RecyclerView

android:focusable="false"
android:focudeableInTouchMode="false"

yo can also use descendantFocusability here is link for better understanding of Can someone explain descendantFocusability = afterDescendants?哟也可以在这里使用descendantFocusability链接,以便更好地理解Can有人解释descendantFocusability = afterDescendants吗?

and also add android:focusable="true" android:focusableInTouchMode="true" to your recyclerView and try again并将android:focusable="true" android:focusableInTouchMode="true"添加到您的 recyclerView 并重试

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Glide 不加载图像到 ImageView - Glide not loading image into ImageView 使用Glide将图像加载到ImageView中 - Loading Image into ImageView with Glide 通过 Glide 从 Gallery 加载图像到 ImageView - Loading Image From Gallery Into ImageView via Glide 如何在Floide加载图像时使RecyclerView上的ImageView具有尺寸设置? - How to make ImageView on RecyclerView to have a dimension set while Glide is loading the image? 在 RecyclerView 中滚动时,如何阻止 Glide 一遍又一遍地加载图像? - How to stop Glide loading Image over and over again when scrolling in RecyclerView? 在 RecyclerView 中从本地资源加载图像时,Glide、Picasso 或其他图像加载库是否会影响应用程序的性能? - Does Glide, Picasso or other image loading library affects app's performance when loading image from local resources in RecyclerView? 使用 Glide 从 URL 加载图像时出现 IllegalArgumentException? - IllegalArgumentException when loading Image from URL with Glide? 使用Glide将应用程序图像图标加载到imageView - Loading Application Image icon in to imageView Using Glide 如何使用Glide在Firebase的回收器视图中将Image设置为imageview? - How to Set Image to imageview in recycler view from Firebase using Glide? 如何使用滑动将GIF图像从可绘制文件夹加载到ImageView中? - How to load GIF image from drawable folder into ImageView using glide?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM