Java Android Webview布局未正确显示
我已经构建了一个显示许可协议的示例Webview页面。它在android Kitkat上工作得很好,文本适合页面,您可以向下滚动 但是,当我尝试在android 9或10上运行时,文本无法正确显示,如下面的屏幕截图所示 我做错了什么 更新:此行导致以下情况:Java Android Webview布局未正确显示,java,android,layout,android-webview,Java,Android,Layout,Android Webview,我已经构建了一个显示许可协议的示例Webview页面。它在android Kitkat上工作得很好,文本适合页面,您可以向下滚动 但是,当我尝试在android 9或10上运行时,文本无法正确显示,如下面的屏幕截图所示 我做错了什么 更新:此行导致以下情况: "<FONT COLOR=\"#0000ff\"><FONT SIZE=2><U>www.capturedoc.com</U></FONT></FON
"<FONT COLOR=\"#0000ff\"><FONT SIZE=2><U>www.capturedoc.com</U></FONT></FONT></A><FONT SIZE=2>.</FONT></P>\n" +
“www.capturedoc.com.\n”+
当前结果(Android 9)
预期结果(Android Kitkat)
许可协议活动
WebView licAgreementTextView = (WebView) findViewById(R.id.lic_agreement);
String str = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n" +
"<HTML>\n" +
"<HEAD>\n" +
"<META HTTP-EQUIV=\"CONTENT-TYPE\" CONTENT=\"text/html; charset=us-ascii\">\n" +
"<TITLE></TITLE>\n" +
"<META NAME=\"GENERATOR\" CONTENT=\"OpenOffice 4.1.1 (FreeBSD/amd64)\">\n" +
"<META NAME=\"CREATED\" CONTENT=\"20180125;11134000\">\n" +
"<META NAME=\"CHANGED\" CONTENT=\"0;0\">\n" +
"<STYLE TYPE=\"text/css\">\n" +
"\t<!--\n" +
"\t\t@page { margin: 0.5in }\n" +
"\t\tP { margin-bottom: 0.08in }\n" +
"\t\tA:link { so-language: zxx }\n" +
"\t-->\n" +
"\t</STYLE>\n" +
"</HEAD>\n" +
"<BODY LANG=\"en-US\" DIR=\"LTR\" STYLE=\"border: none; padding: 0in\">\n" +
"<P STYLE=\"margin-top: 0.07in; margin-bottom: 0.07in\"><FONT SIZE=2>This \n" +
"End-User License Agreement (“Agreement”) governs your use \n" +
"of the CaptureDoc Mobile Application software (“Software”) \n" +
"provided by CaptureDoc, Inc and its affiliates (“CaptureDoc”).\n" +
"Your use of the Software constitutes your acceptance of the terms of \n" +
"this Agreement. Your use of the Software is also subject to the \n" +
"signed agreement between CaptureDoc and your employer or in the \n" +
"absence of a signed agreement, Capturedoc’s standard license\n" +
"terms as made available at " +
"</FONT><A HREF=\"http://www.capturedoc.com/\">" +
"<FONT COLOR=\"#0000ff\"><FONT SIZE=2><U>www.capturedoc.com</U></FONT></FONT></A><FONT SIZE=2>.</FONT></P>\n" +
"<P STYLE=\"margin-top: 0.07in; margin-bottom: 0.07in\"><FONT SIZE=2><B>1.\n" +
"License.</B></FONT><FONT SIZE=2> The Software, in object code form only, solely on your mobile device.\n" +
"You agree to the following license restrictions: (a) to not \n" +
"duplicate, copy or redistribute the Software except as necessary for \n" +
"use on your mobile device; and (b) to not modify, translate, make \n" +
"derivative works of, disassemble, reverse engineer or otherwise use \n" +
"the Software in order to build competitive technologies or for \n" +
"competitive benchmark purposes.</FONT></P>\n" +
"<P STYLE=\"margin-top: 0.07in; margin-bottom: 0.07in\"><FONT SIZE=2><B>2.\n" +
"Generally.</B></FONT><FONT SIZE=2> You agree that CaptureDoc shall not \n" +
"have any liability to you for your use of the Software, including not \n" +
"limited to your access or creation of content using the Software. By \n" +
"using the Software, you acknowledge and agree that CaptureDoc is not \n" +
"responsible for examining or evaluating the content, accuracy,\n" +
"completeness, timeliness, validity, copyright compliance, legality,\n" +
"decency, quality or any other aspect of the content accessed or \n" +
"created by You. You further agree not to use the Software to infringe\n" +
"or violate the rights of any other party, and that CaptureDoc is not \n" +
"in any way responsible for any such use by you. </FONT>\n" +
"</P>\n" +
"<P STYLE=\"margin-top: 0.07in; margin-bottom: 0.07in\"><FONT SIZE=2>CaptureDoc \n" +
"reserves the right to change, terminate, or disable access to the \n" +
"Software as is reasonably necessary to ensure compliance with this \n" +
"Agreement. In no event will CaptureDoc be liable for the change,\n" +
"removal of, termination, or disabling of access to the Software. </FONT>\n" +
"</P>\n" +
"<P STYLE=\"margin-top: 0.07in; margin-bottom: 0.07in\"><FONT SIZE=2><B>3.\n" +
"Limitation Of Liability.</B></FONT><FONT SIZE=2> To the extent not \n" +
"prohibited by law, in no event shall CaptureDoc be liable for personal \n" +
"injury, or any incidental, special, indirect or consequential \n" +
"damages, including, without limitation, damages for loss of profits,\n" +
"loss of data, business interruption or any other commercial damages \n" +
"or losses, arising out of or related to your use or inability to use \n" +
"the Software or Services, however caused, regardless of the theory of \n" +
"liability (contract, tort or otherwise) and even if CaptureDoc has \n" +
"been advised of the possibility of such damages. In no event shall \n" +
"CaptureDoc’s total liability to you for all damages (other than\n" +
"as may be required by applicable law in cases involving personal \n" +
"injury) exceed the amount price paid for the Software, if any. The \n" +
"foregoing limitations will apply even if the above stated remedy \n" +
"fails of its essential purpose.</FONT></P>\n" +
"<P STYLE=\"margin-top: 0.07in; margin-bottom: 0.07in\"><FONT SIZE=2>Some \n" +
"jurisdictions do not allow the limitation of liability for personal \n" +
"injury, or of incidental or consequential damages, so this limitation \n" +
"may not apply to you.</FONT></P>\n" +
"<P STYLE=\"margin-top: 0.07in; margin-bottom: 0.07in\"><FONT SIZE=2><B>4.\n" +
"Indemnification By You.</B></FONT><FONT SIZE=2> You agree to \n" +
"indemnify and hold CaptureDoc, its subsidiaries, and affiliates, and \n" +
"their respective officers, agents, partners and employees, harmless \n" +
"from any loss, liability, claim or demand, including reasonable \n" +
"attorney’s fees, made by any third party due to or arising out \n" +
"of your use of the Software in violation of this Agreement, and in \n" +
"the event that any content accessed or created by you causes \n" +
"CaptureDoc to be liable to another.</FONT></P>\n" +
"</BODY>\n" +
"</HTML>";
licAgreementTextView.loadData(str, "text/html; charset=utf-8", "UTF-8" );
}
WebView-licAgreementTextView=(WebView)findViewById(R.id.lic_协议);
字符串str=“\n”+
“\n”+
“\n”+
“\n”+
“\n”+
“\n”+
“\n”+
“\n”+
“\n”+
“\t\n”+
“\t\n”+
“\n”+
“\n”+
“此\n”+
“最终用户许可协议(&ldquo;协议&rdquo;)控制您的使用\n”+
“CaptureDoc移动应用程序软件(&ldquo;软件&rdquo;)的名称\n”+
由CaptureDoc,Inc及其附属公司(“CaptureDoc”)提供。\n+
“您使用本软件即表示您接受以下条款\n”+
“此协议。您对软件的使用也受\n”+
“CaptureDoc与您的雇主或在中签署的协议\n”+
没有签署的协议,Capturedoc的标准许可证\n+
“在提供的条款”+
“
\n”+
“1。\n+
许可证。该软件仅以目标代码的形式存在于您的移动设备上。\n+
“您同意以下许可证限制:(a)不\n”+
复制、复制或重新分发软件,但必要时除外\n+
在移动设备上使用;和(b)不修改、翻译、制作\n+
衍生作品、拆解、逆向工程或其他用途\n+
“该软件用于构建有竞争力的技术或用于\n”+
“竞争基准目的。
\n”+
“2。\n+
“一般来说。您同意CaptureDoc不应\n”+
对您使用本软件负有任何责任,包括\n+
“仅限于您使用软件访问或创建内容。由\n”+
使用软件时,您确认并同意CaptureDoc不可用\n+
负责检查或评估内容、准确性,\n+
完整性、及时性、有效性、版权合规性、合法性\n+
所访问内容的外观、质量或任何其他方面\n+
“由您创建。您进一步同意不使用该软件侵犯\n”+
或侵犯任何其他方的权利,并且CaptureDoc不是\n+
“以任何方式对您的任何此类使用负责。\n”+
“
\n”+
“CaptureDoc\n”+
保留更改、终止或禁用对\n+
“为确保符合此要求而合理需要的软件\n”+
协议。在任何情况下,CaptureDoc都不对更改负责,\n+
删除、终止或禁用对软件的访问。\n+
“
\n”+
“3。\n”+
“责任限制。在不允许的范围内\n”+
“法律禁止,CaptureDoc在任何情况下都不对个人隐私负责\n”+
伤害,或任何附带的、特殊的、间接的或后果性的\n+
损害赔偿,包括但不限于利润损失的损害赔偿,\n+
数据丢失、业务中断或任何其他商业损害\n+
或因您的使用或无法使用而产生或与之相关的损失\n+
无论是何种原因导致的软件或服务,\n+
责任(合同、侵权或其他),即使CaptureDoc+
“已被告知此类损害的可能性。在任何情况下均不得\n”+
“CaptureDoc对您的所有损失承担的全部责任(不包括\n”+
“在涉及个人隐私的案件中,适用法律可能要求\n”+
“伤害)超过为软件支付的价格金额(如果有)。该\n”+
“即使上述补救措施无效,上述限制也适用\n”+
“没有达到其基本目的。
\n”+
“一些\n”+
“司法管辖区不允许对个人的责任进行限制\n”+
伤害,或偶然或间接损害,因此此限制\n+
“可能不适用于您。
\n”+
“4。\n+
“您的赔偿。您同意\n”+
赔偿并持有CaptureDoc、其子公司和附属公司,以及+
他们各自的高级职员、代理人、合作伙伴和雇员+
任何损失、责任、索赔或要求,包括合理的\n+
由任何第三方支付的由于或产生的律师费\n+
您违反本协议使用本软件,并且\n+
“您访问或创建的任何内容导致的事件\n”+
“CaptureDoc将对另一方负责。
\n”+
“\n”+
"";
利卡
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".copyright.LicenseAgreementActivity"
tools:showIn="@layout/activity_license_agreement">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
tools:layout_editor_absoluteX="30dp"
tools:layout_editor_absoluteY="30dp">
<WebView
android:id="@+id/lic_agreement"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
WebView wbv = findViewById(R.id.wbview);
String html = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n" +
"<HTML>\n" +
"<HEAD>\n" +
"<META HTTP-EQUIV=\"CONTENT-TYPE\" CONTENT=\"text/html; charset=us-ascii\">\n" +
"<TITLE></TITLE>\n" +
"<META NAME=\"GENERATOR\" CONTENT=\"OpenOffice 4.1.1 (FreeBSD/amd64)\">\n" +
"<META NAME=\"CREATED\" CONTENT=\"20180125;11134000\">\n" +
"<META NAME=\"CHANGED\" CONTENT=\"0;0\">\n" +
"<STYLE TYPE=\"text/css\">\n" +
"\t<!--\n" +
"\t\t@page { margin: 0.5in }\n" +
"\t\tP { margin-bottom: 0.08in }\n" +
"\t\tA:link { so-language: zxx }\n" +
"\t-->\n" +
"\t</STYLE>\n" +
"</HEAD>\n" +
"<BODY LANG=\"en-US\" DIR=\"LTR\" STYLE=\"border: none; padding: 0in\">\n" +
"<P STYLE=\"margin-top: 0.07in; margin-bottom: 0.07in\"><FONT SIZE=2>This \n" +
"End-User License Agreement (“Agreement”) governs your use \n" +
"of the CaptureDoc Mobile Application software (“Software”) \n" +
"provided by CaptureDoc, Inc and its affiliates (“CaptureDoc”).\n" +
"Your use of the Software constitutes your acceptance of the terms of \n" +
"this Agreement. Your use of the Software is also subject to the \n" +
"signed agreement between CaptureDoc and your employer or in the \n" +
"absence of a signed agreement, Capturedoc’s standard license\n" +
"terms as made available at " +
"</FONT><A HREF=\"http://www.capturedoc.com/\">" +
"<FONT COLOR=\"#0000ff\"><FONT SIZE=2><U>www.capturedoc.com</U></FONT></FONT></A><FONT SIZE=2>.</FONT></P>\n" +
"<P STYLE=\"margin-top: 0.07in; margin-bottom: 0.07in\"><FONT SIZE=2><B>1.\n" +
"License.</B></FONT><FONT SIZE=2> The Software, in object code form only, solely on your mobile device.\n" +
"You agree to the following license restrictions: (a) to not \n" +
"duplicate, copy or redistribute the Software except as necessary for \n" +
"use on your mobile device; and (b) to not modify, translate, make \n" +
"derivative works of, disassemble, reverse engineer or otherwise use \n" +
"the Software in order to build competitive technologies or for \n" +
"competitive benchmark purposes.</FONT></P>\n" +
"<P STYLE=\"margin-top: 0.07in; margin-bottom: 0.07in\"><FONT SIZE=2><B>2.\n" +
"Generally.</B></FONT><FONT SIZE=2> You agree that CaptureDoc shall not \n" +
"have any liability to you for your use of the Software, including not \n" +
"limited to your access or creation of content using the Software. By \n" +
"using the Software, you acknowledge and agree that CaptureDoc is not \n" +
"responsible for examining or evaluating the content, accuracy,\n" +
"completeness, timeliness, validity, copyright compliance, legality,\n" +
"decency, quality or any other aspect of the content accessed or \n" +
"created by You. You further agree not to use the Software to infringe\n" +
"or violate the rights of any other party, and that CaptureDoc is not \n" +
"in any way responsible for any such use by you. </FONT>\n" +
"</P>\n" +
"<P STYLE=\"margin-top: 0.07in; margin-bottom: 0.07in\"><FONT SIZE=2>CaptureDoc \n" +
"reserves the right to change, terminate, or disable access to the \n" +
"Software as is reasonably necessary to ensure compliance with this \n" +
"Agreement. In no event will CaptureDoc be liable for the change,\n" +
"removal of, termination, or disabling of access to the Software. </FONT>\n" +
"</P>\n" +
"<P STYLE=\"margin-top: 0.07in; margin-bottom: 0.07in\"><FONT SIZE=2><B>3.\n" +
"Limitation Of Liability.</B></FONT><FONT SIZE=2> To the extent not \n" +
"prohibited by law, in no event shall CaptureDoc be liable for personal \n" +
"injury, or any incidental, special, indirect or consequential \n" +
"damages, including, without limitation, damages for loss of profits,\n" +
"loss of data, business interruption or any other commercial damages \n" +
"or losses, arising out of or related to your use or inability to use \n" +
"the Software or Services, however caused, regardless of the theory of \n" +
"liability (contract, tort or otherwise) and even if CaptureDoc has \n" +
"been advised of the possibility of such damages. In no event shall \n" +
"CaptureDoc’s total liability to you for all damages (other than\n" +
"as may be required by applicable law in cases involving personal \n" +
"injury) exceed the amount price paid for the Software, if any. The \n" +
"foregoing limitations will apply even if the above stated remedy \n" +
"fails of its essential purpose.</FONT></P>\n" +
"<P STYLE=\"margin-top: 0.07in; margin-bottom: 0.07in\"><FONT SIZE=2>Some \n" +
"jurisdictions do not allow the limitation of liability for personal \n" +
"injury, or of incidental or consequential damages, so this limitation \n" +
"may not apply to you.</FONT></P>\n" +
"<P STYLE=\"margin-top: 0.07in; margin-bottom: 0.07in\"><FONT SIZE=2><B>4.\n" +
"Indemnification By You.</B></FONT><FONT SIZE=2> You agree to \n" +
"indemnify and hold CaptureDoc, its subsidiaries, and affiliates, and \n" +
"their respective officers, agents, partners and employees, harmless \n" +
"from any loss, liability, claim or demand, including reasonable \n" +
"attorney’s fees, made by any third party due to or arising out \n" +
"of your use of the Software in violation of this Agreement, and in \n" +
"the event that any content accessed or created by you causes \n" +
"CaptureDoc to be liable to another.</FONT></P>\n" +
"</BODY>\n" +
"</HTML>";
wbv.loadData(html, "text/html", "UTF-8");
" <FONT COLOR=\"blue\">" +
" <FONT SIZE=2>" +
" <U>www.capturedoc.com</U>" +
" </FONT>" +
" </FONT>" +
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:padding="20dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<WebView
android:id="@+id/lic_agreement"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
"<FONT COLOR=\"#0000ff\"><FONT SIZE=2><U>www.capturedoc.com</U></FONT></FONT></A><FONT SIZE=2>.</FONT></P>\n"
String unencodedHtml =
"<html><body>'%28' is the code for '('</body></html>";
String encodedHtml = Base64.encodeToString(unencodedHtml.getBytes(), Base64.NO_PADDING);
webView.loadData(encodedHtml, "text/html", "base64");