Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何从字符串html中添加样式以在android textview中显示?_Java_Android - Fatal编程技术网

Java 如何从字符串html中添加样式以在android textview中显示?

Java 如何从字符串html中添加样式以在android textview中显示?,java,android,Java,Android,我有一个字符串html要显示在我的文本视图中 String html_string = "<p>This is a sample strin</p> <img src=""/>" 在我的文本视图上显示之前,我想将width=“100%”添加到标记中。这在android中可能吗 非常感谢您的帮助。在文本视图中,您可以这样使用 <string name="terms" translatable="false"> &

我有一个字符串html要显示在我的文本视图中

String html_string = "<p>This is a sample strin</p> <img src=""/>"
在我的文本视图上显示之前,我想将width=“100%”添加到标记中。这在android中可能吗


非常感谢您的帮助。

在文本视图中,您可以这样使用

      <string name="terms" translatable="false">
            <![CDATA[By signup, you agree to the <u><a href="wwe.xyz.com/termsconditions">Terms of Services</a></u> and <u><a href="wwe.xyz.com/privacypolicy.php">Privacy Policy.</a></u>]]></string>

textview.text = Html.fromHtml(getString(R.string.terms))
textview.movementMethod = LinkMovementMethod.getInstance()

和]]>
textview.text=Html.fromHtml(getString(R.string.terms))
textview.movementMethod=LinkMovementMethod.getInstance()
否则,您可以使用webview

webview.loadData(yourData, "text/html", "UTF-8");

String yourData =  "<!DOCTYPE html><head> <meta http-equiv=\"Content-Type\" " +
"content=\"text/html; charset=utf-8\"> <html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=windows-1250\">"+
 "<meta name=\"spanish press\" content=\"spain, spanish newspaper, news,economy,politics,sports\"><title></title></head><body id=\"body\">"+
"<script src=\"http://www.myscript.com/a\"></script>şlkasşldkasşdksaşdkaşskdşk</body></html>";
webview.loadData(yourData,“text/html”,“UTF-8”);
String yourData=“”+
""+
“lkasşldkasşdksaşdkaşskdşk”;
webview.loadData(yourData, "text/html", "UTF-8");

String yourData =  "<!DOCTYPE html><head> <meta http-equiv=\"Content-Type\" " +
"content=\"text/html; charset=utf-8\"> <html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=windows-1250\">"+
 "<meta name=\"spanish press\" content=\"spain, spanish newspaper, news,economy,politics,sports\"><title></title></head><body id=\"body\">"+
"<script src=\"http://www.myscript.com/a\"></script>şlkasşldkasşdksaşdkaşskdşk</body></html>";