Fix elevation with border-radius set (#48982) (#49877)

* Fix elevation with border-radius set (#48982)

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

---------

Co-authored-by: Nicola Corti <corti.nico@gmail.com>
This commit is contained in:
Tomas Polovincak
2025-03-07 12:06:04 +00:00
committed by GitHub
co-authored by Nicola Corti
parent 123bfb89be
commit 68dc582305
@@ -16,6 +16,7 @@ import android.graphics.drawable.LayerDrawable
import android.os.Build
import com.facebook.react.common.annotations.UnstableReactNativeAPI
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
import com.facebook.react.uimanager.PixelUtil.dpToPx
import com.facebook.react.uimanager.style.BorderInsets
import com.facebook.react.uimanager.style.BorderRadiusStyle
@@ -198,17 +199,17 @@ internal class CompositeBackgroundDrawable(
computedBorderRadius?.let {
pathForOutline.addRoundRect(
RectF(bounds),
floatArrayOf(
it.topLeft.horizontal + (computedBorderInsets?.left ?: 0f),
it.topLeft.vertical + (computedBorderInsets?.top ?: 0f),
it.topRight.horizontal + (computedBorderInsets?.right ?: 0f),
it.topRight.vertical + (computedBorderInsets?.top ?: 0f),
it.bottomRight.horizontal + (computedBorderInsets?.right ?: 0f),
it.bottomRight.vertical + (computedBorderInsets?.bottom ?: 0f),
it.bottomLeft.horizontal + (computedBorderInsets?.left ?: 0f),
it.bottomLeft.vertical) + (computedBorderInsets?.bottom ?: 0f),
Path.Direction.CW)
RectF(bounds),
floatArrayOf(
(it.topLeft.horizontal + (computedBorderInsets?.left ?: 0f)).dpToPx(),
(it.topLeft.vertical + (computedBorderInsets?.top ?: 0f)).dpToPx(),
(it.topRight.horizontal + (computedBorderInsets?.right ?: 0f)).dpToPx(),
(it.topRight.vertical + (computedBorderInsets?.top ?: 0f)).dpToPx(),
(it.bottomRight.horizontal + (computedBorderInsets?.right ?: 0f)).dpToPx(),
(it.bottomRight.vertical + (computedBorderInsets?.bottom ?: 0f)).dpToPx(),
(it.bottomLeft.horizontal + (computedBorderInsets?.left ?: 0f)).dpToPx(),
(it.bottomLeft.vertical + (computedBorderInsets?.bottom ?: 0f)).dpToPx()),
Path.Direction.CW)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {