Skip to content

Commit

Permalink
Add workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
rlepinski committed Aug 7, 2024
1 parent 214da0e commit cb6b028
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit cb6b028

Please sign in to comment.