SDKLauncher-Android icon indicating copy to clipboard operation
SDKLauncher-Android copied to clipboard

Book content does not render when Android WebView is not full-screen

Open msintov opened this issue 9 years ago • 1 comments

I ran into an issue with Android WebView in my project where the viewport div inside reader.html would not appear because its height was getting set to 0.

This bug does not happen when the Android WebView is set to be the only view of the Activity with call Activity.setContentView(myWebView), which is how SDKLauncher-Android adds the WebView to the view hierarchy. The bug happens when the WebView is set to only part of the screen. This seems to be a bug with Android WebView. I only tested on Lollipop.

When the bug happens, the book content inside the viewport div in reader.html does not render because the height for the div was getting set to 0, even though the div is the only thing in the body, and the body height is set to 100% in sdk.css.

In the end, to fix this problem, we found that either the div or the body height had to be set to a specific value in order for the div to appear. For instance, we found these 3 ways to make the div appear (there may be other options):

  1. In the html, add a script tag to the body to set the div height (with padding around the content) immediately after the viewport div is defined. Here is the script tag I used:
  2. In the css, change the body "height: 100%" setting to instead be a specific setting like "height: 350px"
  3. In the html, add a setting to the div to specify the div height to a px setting

This issue stumped me for awhile. The only clue I found in the logs was that onIsMediaOverlayAvailable was getting set to false instead of true when the viewport height was 0.

Please let me know how else I can help. Thank you!

msintov avatar May 07 '15 17:05 msintov

Interesting. It's not a behaviour that other Lollipop (Android 5) users have come across. Thanks for reporting!

danielweck avatar May 22 '15 10:05 danielweck