Skip to content

Commit f2e412a

Browse files
committed
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
1 parent c31b359 commit f2e412a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

android/src/legacy/java/com/rive/RiveReactNativeView.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ class RiveReactNativeView(context: ThemedReactContext) : FrameLayout(context) {
102102
}
103103

104104
fun configure(config: ViewConfiguration, dataBindingChanged: Boolean, reload: Boolean = false, initialUpdate: Boolean = false) {
105+
// https://github.com/rive-app/rive-nitro-react-native/pull/209
106+
riveAnimationView?.layoutScaleFactor = config.layoutScaleFactor
107+
?: resources.displayMetrics.density
108+
105109
if (reload) {
106110
val hasDataBinding = when (config.bindData) {
107111
is BindData.None -> false
@@ -121,8 +125,6 @@ class RiveReactNativeView(context: ThemedReactContext) : FrameLayout(context) {
121125
} else {
122126
riveAnimationView?.alignment = config.alignment
123127
riveAnimationView?.fit = config.fit
124-
// TODO: this seems to require a reload for the view to take the new value (bug on Android)
125-
riveAnimationView?.layoutScaleFactor = config.layoutScaleFactor
126128
}
127129

128130
if (dataBindingChanged || initialUpdate || reload) {

0 commit comments

Comments
 (0)