简体   繁体   中英

Webview is not displaying table properly in 4.0+ in android

I am using the following code to display content in webview.

    mMessageContentView.setText(emailText, contentType);
    mMessageContentView.scrollTo(0, 0);
    mMessageContentView.getSettings().setUseWideViewPort(true);
    mMessageContentView.getSettings().setJavaScriptEnabled(true);

It is displaying properly in nexus one,samsung player etc,but it is not displaying in Samsung s2(4.0.1),Samsung Nexus(4.2.1)

Here i am attaching the Screen shots of both(Nexus one,Google nexus) Google Nexus ). 在此处输入图片说明

I observed that , In some devices like Samsung Galaxy S2,S3 etc Webview displays the Table in a single column. So i applied the following code to chage the Webview Table setting as Normal.

    mMessageContentView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.NORMAL);

Then it is displaying in Correct format in all the devices.

Do you have the raw HTML from the table? It is impossible to know what is right and wrong without that.

You can also check how it renders in a recent version of Chrome or Safari.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM