10

When I put an item with asynchronically loaded content with expandable height, such as WebView or Fresco's SimpleDraweeView, the view sometimes scrolls to this item (if it's for example just partially visible on the screen, it scrolls to it after item is loaded). Have someone experienced this issue?

winiarro
  • 101
  • 3
  • 1
    I am experiencing this thing exactly, it's really annoying, I have ads (Which shows in Webview) and it forces the RecyclerView to scroll to show the Ad, Did you find any solution for this? – Shehabic Jun 25 '16 at 17:25
  • @Shehabix I've not found solution for that. I dropped the WebView idea and the adverts are just plain image, displayed inside SimpleDraweeView. But I know the exact width and height of the advert from advance, so when I set aspect ratio before loading the image, the issue doesn't exist. I've adressed this issue to Google, but they didn't seem to acknowledge that. – winiarro Jun 27 '16 at 13:37
  • I found that this issue is only Affecting certain versions of Support Lib. for example 23.4.0 is not affected while 23.3 and 24.0.0 are affected – Shehabic Jun 28 '16 at 15:28
  • Someone came up with the answer here: http://stackoverflow.com/questions/37909408/nativeadsexpress-forces-recyclerview-to-scroll-to-have-the-nativead-fully-visibl – Shehabic Jun 28 '16 at 20:45

1 Answers1

18

Put android:descendantFocusability="beforeDescendants" in your layout XML. This will prevent scrolling to asynchronously loaded contents.

<android.support.v7.widget.RecyclerView
            android:id="@+id/my_list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:descendantFocusability="beforeDescendants" />
DavidE
  • 181
  • 1
  • 5