Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
477 views
in Technique[技术] by (71.8m points)

javascript - Android WebView viewport inside ScrollView not working

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:

  1. Forward the "visible frame" to my WebView so that the player has the correct scrolling/viewport variables in JS, or
  2. 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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...