Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebView inside ScrollView seems to work fine, but warnings to not use - alternative?

Everything I've read (AFTER already making my app :( ) says something like "you should never use a WebView inside a ScrollView!". This is understandable because you could theoretically have 2 scrolling things which would make for odd usability.

But - so far, I've seen no adverse effects. Then again, each WebView I'm using doesn't require scrolling - maybe that makes it acceptable-use even though it's technically wrong?

Are there adverse effects that I'm just not noticing to due lack of testing on a specific version(s)?

If I can't use a WebView inside a ScrollView, how would I get the below layout (my current app):

LinearLayout
    ScrollView
        LinearLayout
            TextView //Title of article
            TextView //Subtitle of article
            RelativeLayout
                ImageView //Large Image (clickable to gallery)
                ImageView //"more photos icon"
            WebView // a small horizontal ad
            TextView // actual article text
            WebView //embedded HTML code ranging from iframe to video...etc
            WebView //embedded HTML code ranging from iframe to video...etc
            WebView // a small horizontal ad
            LinearLayout
                TextView //DB-driven "similar articles" list
            WebView //disqus comments

Note: I realize it's "wrong" - but so are using <center> tags in HTML, and people still use them all the time effectively. The difference seems to be that there's an easy-and-better alternative to <center> - is there something similar for this scenario in Android? A somewhat-simple way to get the above?

like image 233
Dave Avatar asked Oct 06 '22 08:10

Dave


1 Answers

This is understandable because you could theoretically have 2 scrolling things which would make for odd usability.

More specifically, ScrollView is as dumb as a box of rocks, and assumes it has full control over scrolling.

Then again, each WebView I'm using doesn't require scrolling

More accurately, it doesn't require scrolling on the devices that you have tested, and for the content that you have tested.

For example, DISQUS comment threads typically require scrolling on a desktop browser. One imagines that there will be comment threads that will be long enough to require scrolling on a mobile device, unless there is a scroll-free DISQUS embed you can use.

If I can't use a WebView inside a ScrollView, how would I get the below layout (my current app):

Get rid of everything and have a single WebView, with generated HTML content that contains all the stuff in your current structure. IOW, do what you would do in a Web site.

like image 83
CommonsWare Avatar answered Oct 10 '22 04:10

CommonsWare