如何将WebView的背景颜色设置为十六进制值?

Jas*_*ing 8 android webview android-layout

如何将a的背景颜色设置WebView为十六进制值?我对通过main.xml或以编程方式开放.

Smi*_*Smi 16

假设您已WebView在XML资源中定义了您,您可以执行以下操作:

WebView myWebView = (WebView) findViewById(R.id.myWebView);
myWebView.setBackgroundColor(Color.parseColor("#000000"));
Run Code Online (Sandbox Code Playgroud)


Arc*_*pgc 11

在xml中:

<WebView
android:background = "#7CFC00"
/>
Run Code Online (Sandbox Code Playgroud)

绿色等..