From cb6b02807b4672ee5cf20491f1d67ef88ffef941 Mon Sep 17 00:00:00 2001 From: Ryan Lepinski Date: Tue, 6 Aug 2024 17:03:56 -0700 Subject: [PATCH] Add workaround --- .../reactnative/ReactEmbeddedView.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/android/src/main/java/com/urbanairship/reactnative/ReactEmbeddedView.kt b/android/src/main/java/com/urbanairship/reactnative/ReactEmbeddedView.kt index f5f446ed..ed5bf052 100644 --- a/android/src/main/java/com/urbanairship/reactnative/ReactEmbeddedView.kt +++ b/android/src/main/java/com/urbanairship/reactnative/ReactEmbeddedView.kt @@ -40,4 +40,20 @@ class ReactEmbeddedView(context: Context) : FrameLayout(context), LifecycleEvent override fun onHostDestroy() { } + + override fun requestLayout() { + + super.requestLayout() + + // This view relies on a measure + layout pass happening after it calls requestLayout(). + // https://github.com/facebook/react-native/issues/4990#issuecomment-180415510 + // https://stackoverflow.com/questions/39836356/react-native-resize-custom-ui-component + post(measureAndLayout) + } + + private val measureAndLayout = Runnable { + measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), + MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)) + layout(left, top, right, bottom) + } } \ No newline at end of file