需要Android字符串HTML帮助

需要Android字符串HTML帮助,android,html,Android,Html,所以在安卓系统中,我想证明文本的合理性,所以我决定使用Webview。它工作得很好,但我唯一的问题是我的应用程序的背景不是白色的。所以每当我看到文本,它总是有一个白色的背景。那么我可以添加一个body标签来改变背景颜色吗 String text = "<html><body style=\"text-align:justify\"> %s </body> </Html> "; // I want to include a body tag

所以在安卓系统中,我想证明文本的合理性,所以我决定使用Webview。它工作得很好,但我唯一的问题是我的应用程序的背景不是白色的。所以每当我看到文本,它总是有一个白色的背景。那么我可以添加一个body标签来改变背景颜色吗

String text = "<html><body style=\"text-align:justify\"> %s </body> </Html> ";
     // I want to include a body tag above which will make the background this color = #e6e6e6
       String data = "My Text";

       WebView webView = (WebView) findViewById(R.id.WebView);
       webView.loadData(String.format(text, data), "text/html", "utf-8");
String text=“%s”;
//我想在上面添加一个body标记,它将使背景为这种颜色=#e6
String data=“我的文本”;
WebView WebView=(WebView)findViewById(R.id.WebView);
loadData(String.format(text,data),“text/html”,“utf-8”);

查看以下链接。

它解释了android中的justify规则。如何在webview中执行此操作,它还有一个支持库,您可以使用它执行本机操作

试一试

用于透明背景。

尝试:

String text = "<html><body style=\"text-align:justify; background-color:#e6e6e6;\"> %s </body></html>"
String text=“%s”
background color
CSS属性应该允许您将背景设置为您想要的任何颜色

编辑:KalelWade的答案更好,因为它是通过Android属性而不是HTML完成的

String text = "<html><body style=\"text-align:justify; background-color:#e6e6e6;\"> %s </body></html>"