From 0bf8e213d9256bda197149a09d273cd78605ca45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Fazekas?= Date: Fri, 10 Apr 2026 16:25:14 +0200 Subject: [PATCH] Fix Fit.LAYOUT artboard oversized on Android Set layoutScaleFactor to device density before setRiveFile when the user hasn't set an explicit value. layoutScaleFactorAutomatic defaults to 1.0 and onMeasure may not fire before the render thread uses it. Fixes #206 --- android/src/main/java/com/rive/RiveReactNativeView.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/rive/RiveReactNativeView.kt b/android/src/main/java/com/rive/RiveReactNativeView.kt index 7753d936..a1d75cba 100644 --- a/android/src/main/java/com/rive/RiveReactNativeView.kt +++ b/android/src/main/java/com/rive/RiveReactNativeView.kt @@ -102,6 +102,10 @@ class RiveReactNativeView(context: ThemedReactContext) : FrameLayout(context) { } fun configure(config: ViewConfiguration, dataBindingChanged: Boolean, reload: Boolean = false, initialUpdate: Boolean = false) { + // https://github.com/rive-app/rive-nitro-react-native/pull/209 + riveAnimationView?.layoutScaleFactor = config.layoutScaleFactor + ?: resources.displayMetrics.density + if (reload) { val hasDataBinding = when (config.bindData) { is BindData.None -> false @@ -121,8 +125,6 @@ class RiveReactNativeView(context: ThemedReactContext) : FrameLayout(context) { } else { riveAnimationView?.alignment = config.alignment riveAnimationView?.fit = config.fit - // TODO: this seems to require a reload for the view to take the new value (bug on Android) - riveAnimationView?.layoutScaleFactor = config.layoutScaleFactor } if (dataBindingChanged || initialUpdate || reload) {