[英]How to add style in html by htm.fromHtml() for java(android)
下面给出了我的 html 页面---
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</head>
<style type="text/css">
body{
margin: 0;
padding: 0;
width:100%;
height: 100%;
}
h5{
text-align: center;
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
height: 30px;
font-size: 27px;
background-position: center;
color: Black;
padding: 75px;
background-size: contain;
}
</style>
<body>
<h5>
সমাপ্ত
</h5>
</body>
</html>
我在android中通过以下功能实现了这个html页面,但它只是显示文本,CSS不起作用!
Spannable sequence = (Spannable) Html.fromHtml("<!DOCTYPE HTML>\n" +
"<html lang=\"en-US\">\n" +
"<head>\n" +
"\t<meta charset=\"UTF-8\">\n" +
"\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n" +
"\t<title></title>\n" +
"</head>\n" +
"<style type=\"text/css\">\n" +
"body{\n" +
"margin: 0;\n" +
"padding: 0;\n" +
"width:100%;\n" +
"height: 100%;\n" +
"\n" +
"\n" +
"}\n" +
"h5{\n" +
" text-align: center;\n" +
" margin: auto;\n" +
" position: absolute;\n" +
" top: 0;\n" +
" left: 0;\n" +
" bottom: 0;\n" +
" right: 0;\n" +
" height: 30px;\n" +
" font-size: 27px;\n" +
" background-position: center;\n" +
" color: Black;\n" +
" padding: 75px;\n" +
" background-size: contain;\n" +
"}\n" +
"</style>\n" +
"<body>\n" +
"\t<h5>\n" +
"\t\tসমাপ্ত\n" +
"\t</h5>\n" +
"</body>\n" +
"</html>");
但只有 html 文本显示,CSS 不起作用..我该怎么办? 任何帮助都是快乐
您不能使用所有HTML
标签和属性,请参阅 此博客,其中列出了Html.fromHTML
所有支持的标签
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.