Skip to content

Fix Android border disappearing when the background drawable alpha is set - #59965

Open
lazerg wants to merge 1 commit into
react:mainfrom
lazerg:fix/issue-59963-border-drawable-alpha
Open

lazerg wants to merge 1 commit into
react:mainfrom
lazerg:fix/issue-59963-border-drawable-alpha

Conversation

@lazerg

@lazerg lazerg commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Summary:

On Android, setting a view's background drawable alpha to anything from 1 to 254 (for example view.background.alpha = 128) makes its border disappear, while the background color fades as expected. CompositeBackgroundDrawable passes the alpha down to BorderDrawable, and multiplyColorAlpha there computes colorAlpha * (alpha shr 7) shr 8. alpha shr 7 is only ever 0 or 1, so the border color alpha always ends up 0.

It now multiplies by the 0..256 alpha itself, so a border at alpha 128 draws at half its color alpha. 0 and 255 already return early and don't change.

Fixes #59963

Changelog:

[ANDROID] [FIXED] - Setting a view's background drawable alpha no longer makes its border fully transparent

Test Plan:

Added BorderDrawableTest.settingAlphaScalesBorderColorAlpha, which sets alpha = 128 on a drawable with a red border, draws it and checks the border paint alpha is 128. It fails on main (the alpha is 0) and passes with this change. ./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest passes and yarn format-check-kotlin is clean. I didn't run the reproducer on a device.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 12, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Nov 12, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android: setting a view's background drawable alpha anywhere from 1 to 254 makes its border fully transparent

1 participant