I have a Webview loading static html content in my app.
the problem is, when I click on a link or an embed content (tweet, youtube video), the webview is scrolling back to the top.
It looks like a JS problem as mentioned here
I tried to use a NestedScrollView or some tricks with params like
android:focusableInTouchMode="true"
in a LinearLayout parent but nothing works
here's my xml :
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:id="@+id/article_webview"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.v4.widget.NestedScrollView>
it will be in a recycler view.
My question is :
is there a way to prevent this behavior in the webview settings or xml ?
Thanks !
I've been having the same problem. My WebView
was inside a RecyclerView
too.
When I added android:descendantFocusability="blocksDescendants"
on my RecyclerView
, the problem does not happen for me anymore.
<androidx.recyclerview.widget.RecyclerView
android:descendantFocusability="blocksDescendants"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With