更改背景颜色和字体颜色颜色、字体、背景

2023-09-13 00:32:03 作者:后知后觉.

我想改变我的的WebView 的背景颜色和字体大小。

I want to change my WebView's background color and font size.

推荐答案

假设你定义了你的WebView中,你可以做以下的XML布局资源:

Assuming that you have defined your webview in an XML layout resource you can do the following:

WebView myWebView = (WebView) findViewById(R.id.myWebView);
myWebView.setBackgroundColor(Color.parseColor("#000000"));
myWebView.getSettings.setDefaultFontSize(10);

您可能还需要启用javascript并创建一个简单的Web客户端来处理页面加载

You may also want to enable javascript and create a simple WebClient to handle page loading

希望它能帮助!