In our app we have a layout where we need to have some text and buttons above and below a WebView, so inside a CoordinatorLayout
a NestedScrollView
that contains a ConstraintLayout
which contains the other views and a WebView
that has a wrap_content
height, so that its not scrollable, and the whole user's view scrolls using the NestedScrollView
.
However, we have some elements in the WebView (a JS video player) that has some scripts and pauses itself when it is scrolled out of the user's viewport. This behavior works properly in Chrome and in a WebView that has match_parent
height, but not for our embeded-in-scrollview WebView. Is there a way to make this work?
The things we can do is to:
- Forward the "visible frame" to my WebView so that the player has the correct scrolling/viewport variables in JS, or
- Make the videos auto-play in fullscreen and pause them when the user exists the fullscreen. This is not supported by the player, so it has to be done manually. (This is the default behavior on iOS when
allowsInlineMediaPlayback
is set to true, so mimicing that would solve the issue)
Any suggestions for any of the 2?
question from:
https://stackoverflow.com/questions/65841933/android-webview-viewport-inside-scrollview-not-working 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…