Skip to content

Commit 55d5c44

Browse files
jorge-cabrobhogan
authored andcommitted
Fix elevation with border-radius set (facebook#48982)
Summary: Pull Request resolved: facebook#48982 We were missing a conversion to px on the `getOutline()` function of `CompositeBackgroundDrawable` which led to incorrect elevation prop rendering Changelog: [Android][Fixed] - Elevation prop on android has incorrect border-radius Reviewed By: NickGerleman Differential Revision: D68724947 fbshipit-source-id: b3a7a4919bfd7c60fac7c3d6e3ba760e3f74d190
1 parent bc35afe commit 55d5c44

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/CompositeBackgroundDrawable.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import android.graphics.drawable.LayerDrawable
1616
import android.os.Build
1717
import com.facebook.react.common.annotations.UnstableReactNativeAPI
1818
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
19+
import com.facebook.react.uimanager.PixelUtil.dpToPx
1920
import com.facebook.react.uimanager.style.BorderInsets
2021
import com.facebook.react.uimanager.style.BorderRadiusStyle
2122

@@ -200,14 +201,14 @@ internal class CompositeBackgroundDrawable(
200201
pathForOutline.addRoundRect(
201202
RectF(bounds),
202203
floatArrayOf(
203-
it.topLeft.horizontal + (computedBorderInsets?.left ?: 0f),
204-
it.topLeft.vertical + (computedBorderInsets?.top ?: 0f),
205-
it.topRight.horizontal + (computedBorderInsets?.right ?: 0f),
206-
it.topRight.vertical + (computedBorderInsets?.top ?: 0f),
207-
it.bottomRight.horizontal + (computedBorderInsets?.right ?: 0f),
208-
it.bottomRight.vertical + (computedBorderInsets?.bottom ?: 0f),
209-
it.bottomLeft.horizontal + (computedBorderInsets?.left ?: 0f),
210-
it.bottomLeft.vertical) + (computedBorderInsets?.bottom ?: 0f),
204+
(it.topLeft.horizontal + (computedBorderInsets?.left ?: 0f)).dpToPx(),
205+
(it.topLeft.vertical + (computedBorderInsets?.top ?: 0f)).dpToPx(),
206+
(it.topRight.horizontal + (computedBorderInsets?.right ?: 0f)).dpToPx(),
207+
(it.topRight.vertical + (computedBorderInsets?.top ?: 0f)).dpToPx(),
208+
(it.bottomRight.horizontal + (computedBorderInsets?.right ?: 0f)).dpToPx(),
209+
(it.bottomRight.vertical + (computedBorderInsets?.bottom ?: 0f)).dpToPx(),
210+
(it.bottomLeft.horizontal + (computedBorderInsets?.left ?: 0f)).dpToPx(),
211+
(it.bottomLeft.vertical + (computedBorderInsets?.bottom ?: 0f)).dpToPx()),
211212
Path.Direction.CW)
212213
}
213214

0 commit comments

Comments
 (0)