[英]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.