package com.example.webviewtheme;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.webkit.WebView;
public class MainActivity extends Activity {
WebView webview1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webview1=(WebView)findViewById(R.id.webView1);
String rawHTML = "<HTML>"+
"<body style='color: #000000; background-color: #ffffff'><h1>Hello Android </h1></body>"+
"</HTML>";
webview1.setBackgroundColor(00000000);
webview1.loadData(rawHTML, "text/HTML", "UTF-8");
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的代码,我想设置WebView的背景色黑色和文本白色,我尝试在HTML中应用,但无法退出,请帮助我如何在Webview文本和backGround中设置夜间模式
用这个
webview1=(WebView)findViewById(R.id.webView1);
String rawHTML = "<HTML>"+
"<head>"+"<style type=\"text/css\">"+
"body,h1{color: #000000;"+
"background-color: #ffffff;}"+
"</style></head>"+
"<body><h1>Hello Android </h1></body>"+
"</HTML>";
webview1.loadData(rawHTML, "text/html; charset=UTF-8",null);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
30596 次 |
| 最近记录: |