From fab5bdc0cd68fafede4fe680518e3cc0e294413b Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Sat, 14 Oct 2023 13:17:05 +0200 Subject: [PATCH] fix: Fix PreviewView overflowing on Android (#2001) * fix: Run `addView` on UI Thread * fix: Fix overflow of PreviewView --- .../android/src/main/java/com/mrousavy/camera/CameraView.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/package/android/src/main/java/com/mrousavy/camera/CameraView.kt b/package/android/src/main/java/com/mrousavy/camera/CameraView.kt index 7627127..20fb4e8 100644 --- a/package/android/src/main/java/com/mrousavy/camera/CameraView.kt +++ b/package/android/src/main/java/com/mrousavy/camera/CameraView.kt @@ -13,6 +13,7 @@ import android.view.Surface import android.widget.FrameLayout import androidx.core.content.ContextCompat import com.facebook.react.bridge.ReadableMap +import com.facebook.react.bridge.UiThreadUtil import com.mrousavy.camera.core.CameraPermissionError import com.mrousavy.camera.core.CameraQueues import com.mrousavy.camera.core.CameraSession @@ -113,6 +114,7 @@ class CameraView(context: Context) : init { this.installHierarchyFitter() + clipToOutline = true setupPreviewView() cameraSession = CameraSession(context, cameraManager, { invokeOnInitialized() }, { error -> invokeOnError(error) }) } @@ -156,8 +158,10 @@ class CameraView(context: Context) : LayoutParams.MATCH_PARENT, Gravity.CENTER ) - addView(previewView) this.previewView = previewView + UiThreadUtil.runOnUiThread { + addView(previewView) + } } fun update(changedProps: ArrayList) {