From 108e0a64eff59c1783c507e1596eaad8c94d26c2 Mon Sep 17 00:00:00 2001 From: Michael Klimushyn Date: Wed, 5 Sep 2018 16:47:02 -0700 Subject: [PATCH] Add transparency helpers to FlutterView.java (#6172) Fixes #9627 --- .../android/io/flutter/view/FlutterView.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/shell/platform/android/io/flutter/view/FlutterView.java b/shell/platform/android/io/flutter/view/FlutterView.java index 9a3ee9cb9d..8a46370248 100644 --- a/shell/platform/android/io/flutter/view/FlutterView.java +++ b/shell/platform/android/io/flutter/view/FlutterView.java @@ -12,6 +12,7 @@ import android.content.IntentFilter; import android.content.pm.ApplicationInfo; import android.content.res.Configuration; import android.database.ContentObserver; +import android.graphics.PixelFormat; import android.provider.Settings; import android.net.Uri; import android.os.Handler; @@ -276,6 +277,26 @@ public class FlutterView extends SurfaceView mFirstFrameListeners.remove(listener); } + /** + * Updates this to support rendering as a transparent {@link SurfaceView}. + * + * Sets it on top of its window. The background color still needs to be + * controlled from within the Flutter UI itself. + */ + public void enableTransparentBackground() { + setZOrderOnTop(true); + getHolder().setFormat(PixelFormat.TRANSPARENT); + } + + /** + * Reverts this back to the {@link SurfaceView} defaults, at the back of its + * window and opaque. + */ + public void disableTransparentBackground() { + setZOrderOnTop(false); + getHolder().setFormat(PixelFormat.OPAQUE); + } + public void setInitialRoute(String route) { mFlutterNavigationChannel.invokeMethod("setInitialRoute", route); } -- GitLab