It seems to the limitations of WebView.loadData? I also ran into some
weird problems with loadData. Such as cannot display tables. See
http://groups.google.com/group/android-developers/browse_thread/thread/13f9b8850ac048ac/7347368a5adbe905.
But when using WebView.loadUrl, the same html content can display
correctly.

On Mar 22, 4:33 am, Dale <dale.ham...@gmail.com> wrote:
> I am working on an app which needs to display some dynamically queried
> HTML content, including CSS.
> WebView seems to be the best implementation for this type of work.
>
> I ran into an error when testing it out, and tracked it down to the
> following css tag:
>
> hr{width:100%!important}
>
> Android WebView seems to be incapable of displaying any html that
> includes this line.
> Some research shows that the <hr width=100%/> attribute was depricated
> (link:http://www.w3schools.com/tags/att_hr_width.asp), but it works
> on all browsers.
>
> Below is some html, including this line.  It will render fine in any
> browser.
>
> <html><head><style type=\"text/css\">
> hr{width:100%!important}
> </style></head><body>
> Some text
> </body></html>
>
> And, in Android:
>
>                 String exampleCSS = "<html><head><style type=\"text/css\">" +
>                                 "hr{width:100%!important}" +
>                                 "</style></head><body>" +
>                                 "Some text" +
>                                 "</body></html>";
>                 WebView webView = (WebView) findViewById(R.id.web_html_about);
>                 webView.loadData(exampleCSS, "text/html", "utf-8");
>
> The result is a "Web page not available" error in the webview.
>
> Is this a known issue due to deprecation?  Is it a bug with WebView?
> Is there any known work around for such issues?
>
> Cheers,
> Dale.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to