,因为它工作正常,只是改变这种
myWebView.setBackgroundColor(0);
这个
myWebView.setBackgroundColor(Color.BLUE);
。
看到我的全部代码..
XML代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.softeng.abcd.Main2Activity"
tools:showIn="@layout/activity_main2"
>
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webview"></WebView>
</RelativeLayout>
Java代码。
WebView webview = (WebView)findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setLoadWithOverviewMode(true);
webview.getSettings().setUseWideViewPort(true);
webview.getSettings();
webview.setBackgroundColor(Color.BLUE);
输出:
我试过黑色,白色和透明。现在我正在尝试透明。 –
请参阅下面的答案。 – Ironman
不适用于我:-( –