diff --git a/shell/platform/android/io/flutter/view/FlutterView.java b/shell/platform/android/io/flutter/view/FlutterView.java index 9a3ee9cb9d55ff19752f1c57423ff79c77834c28..8a463702483656e8dd8c4e7a7d78a12bd6779ad0 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); }