简体   繁体   中英

How to add style in html by htm.fromHtml() for java(android)

My html page below given---

<!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>

I implemented this html page by this below function in android,But it's only display text,CSS is not work!

      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>");

But Only html text show ,CSS not Work..what should i do ? Any help is pleasure

您不能使用所有HTML标签和属性,请参阅 博客,其中列出了Html.fromHTML所有支持的标签

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