diff --git a/packages/webview_flutter/android/src/main/java/io/flutter/plugins/webviewflutter/FlutterWebView.java b/packages/webview_flutter/android/src/main/java/io/flutter/plugins/webviewflutter/FlutterWebView.java index bfb79a39e8ba..074f12be33d0 100644 --- a/packages/webview_flutter/android/src/main/java/io/flutter/plugins/webviewflutter/FlutterWebView.java +++ b/packages/webview_flutter/android/src/main/java/io/flutter/plugins/webviewflutter/FlutterWebView.java @@ -87,7 +87,8 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) { DisplayManager displayManager = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE); displayListenerProxy.onPreWebViewInitialization(displayManager); - webView = new InputAwareWebView(context, containerView); + boolean opaque = (boolean) params.get("opaque"); + webView = new InputAwareWebView(context, containerView, opaque); displayListenerProxy.onPostWebViewInitialization(displayManager); platformThreadHandler = new Handler(context.getMainLooper()); diff --git a/packages/webview_flutter/android/src/main/java/io/flutter/plugins/webviewflutter/InputAwareWebView.java b/packages/webview_flutter/android/src/main/java/io/flutter/plugins/webviewflutter/InputAwareWebView.java index 9b81a5b7cc6b..87023affb371 100644 --- a/packages/webview_flutter/android/src/main/java/io/flutter/plugins/webviewflutter/InputAwareWebView.java +++ b/packages/webview_flutter/android/src/main/java/io/flutter/plugins/webviewflutter/InputAwareWebView.java @@ -31,9 +31,12 @@ final class InputAwareWebView extends WebView { private ThreadedInputConnectionProxyAdapterView proxyAdapterView; private View containerView; - InputAwareWebView(Context context, View containerView) { + InputAwareWebView(Context context, View containerView, boolean opaque) { super(context); this.containerView = containerView; + if (!opaque) { + setBackgroundColor(0x00000000); + } } void setContainerView(View containerView) { diff --git a/packages/webview_flutter/example/lib/main.dart b/packages/webview_flutter/example/lib/main.dart index 7ec3008337d8..5cd50c028504 100644 --- a/packages/webview_flutter/example/lib/main.dart +++ b/packages/webview_flutter/example/lib/main.dart @@ -17,7 +17,7 @@ const String kNavigationExamplePage = ''' Navigation Delegate Example

-The navigation delegate is set to block navigation to the youtube website. +The navigation delegate is set to block navigation to the youtube website, and as the webview background is transparent, you can see scaffold background.