0

In my application there is a WebView and a button.
on button click I receive a HTML from a webservice with AsyncTask.
There are a situation when I receive the same HTML from the service.

The HTML:

<html>
    <head>
    </head>
    <body style="font-family:Arial;">
        <center>No data to display</center>
    </body>
</html>

The strange behavior:
At every odd call (1, 3, 5, ...) the HTML above is centered, every even call the same HTML that aligned to left.
It happens only on Samsung Galaxy 2 and 3 with Android 4 and not happens on Motorola Atrix with Android 2.3.4.

I load the HTML with:

mReportChart.loadDataWithBaseURL("fake://", data.getHtml(), "text/html", "utf-8", "fake://");

The HTML each time is the same.
How can I resolve that problem?

NickF
  • 5,637
  • 12
  • 44
  • 75

2 Answers2

2

Ben is right, the center tag is not standard HTML5, so you can't expect it to work properly. The best solution, if you can, is getting rid of the center tag. But if that's not the case you can just "force" the center tag to be centered with css. Add the following to your stylesheet and it should be fixed:

center {
    margin-left:auto;
    margin-right:auto;
    text-align:center;
}
caiocpricci2
  • 7,714
  • 10
  • 56
  • 88
0

The center tag is deprecated in HTML 4.01 and not supported in HTML 5. I would use CSS to center what you want out.

http://www.w3schools.com/tags/

<div style="text-align: center;">
No data to display
</div>
BenMorel
  • 34,448
  • 50
  • 182
  • 322
Ben P. Dorsi-Todaro
  • 221
  • 1
  • 6
  • 20
  • @NickF Some browsers support some tags others don't. If you want your code to work for most browsers try to stick with the standards. What used to be the standard is no longer the standard and some browsers wont work as you plan if you choose to use older code. – Ben P. Dorsi-Todaro Aug 05 '13 at 09:09
  • Please read again the question, I mentioned that in the same mobile browser of Samsung galaxy one time it looks good and on the other not. – NickF Aug 05 '13 at 09:11
  • @NickF It seems as though your having the issue on only some devices. Please try to stay away from using the center tag and you will have less problems – Ben P. Dorsi-Todaro Aug 05 '13 at 09:16
  • @NickF Please read the following http://stackoverflow.com/questions/1798817/why-is-the-center-tag-deprecated-in-html – Ben P. Dorsi-Todaro Aug 05 '13 at 10:36