【问题标题】:How to clear focus from imageview in Recyclerview when loading image with glide?使用滑行加载图像时如何从 Recyclerview 中的图像视图中清除焦点?
【发布时间】:2020-07-06 20:20:26
【问题描述】:

在 Recyclerview 上使用滑行加载图像时,我发现了一个错误(更可能是错误)。问题是,当我将图像从 URL 加载到 recyclerview 项目上的 imageview 时,imageview 似乎专注于它。这是它的样子:imageview gained focus after load image with glide

这会导致recyclerview 自行滚动(我无法发布视频)。有没有办法解决这个问题?谢谢你,对不起我的英语。

【问题讨论】:

  • 你为什么需要关注这个?
  • 我其实是想清焦
  • 你有解决办法吗?

标签: android kotlin android-recyclerview android-glide


【解决方案1】:

试试这个:

recyclerview.setFocusable(false);

【讨论】:

    【解决方案2】:

    尝试在使用 Glide 加载图像时将 isFocusable 强制设置为 false。 这只是一个尝试,也许它适合你。

    【讨论】:

      【解决方案3】:

      那是因为 RecyclerView 总是设置:

      setFocusableInTouchMode(true);
      

      所以如果你在你的 XML 中为 RecyclerView 应用这些属性

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

      你也可以使用 descendantFocusability 这里是链接以便更好地理解 Can someone explain descendantFocusability = afterDescendants?

      并将 android:focusable="true" android:focusableInTouchMode="true" 添加到您的 recyclerView 并重试

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-03-31
        • 2012-10-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-11-04
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多