Commit 21d1669
committed
fix(android): track textAlignVertical in custom decoration draw offset
ReactTextView.onDraw paints CanvasEffectSpan decorations (underline,
strikethrough) in their own pass, translating by getExtendedPaddingTop()
only. That matches the default Gravity.TOP, but when textAlignVertical is
center or bottom and the text is shorter than the view, super.onDraw shifts
the glyphs down by a gravity offset the span draws were missing, so the
decoration rendered at the top of the box while the text sat centered or at
the bottom.
The offset (mirroring the private TextView.getVerticalOffset()) is now
computed by a package-private verticalGravityOffset() helper and applied to
both the onPreDraw and onDraw translate passes.
## Changelog:
[ANDROID] [FIXED] - Custom text decorations track `textAlignVertical`
## Test Plan:
ReactTextViewTest covers verticalGravityOffset across top, center, bottom,
exact-fit, and overflow cases. Visually: a fixed-height <Text> with
textAlignVertical "center" (and "bottom"), textDecorationLine "underline",
and a distinct textDecorationColor inside a taller parent now renders the
decoration flush under the glyphs; previously it stayed pinned to the top of
the box while the text moved. Verified on Android API 36.1 parent 4adca58 commit 21d1669
2 files changed
Lines changed: 75 additions & 2 deletions
File tree
- packages/react-native/ReactAndroid/src
- main/java/com/facebook/react/views/text
- test/java/com/facebook/react/views/text
Lines changed: 22 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
222 | 228 | | |
223 | | - | |
| 229 | + | |
224 | 230 | | |
225 | 231 | | |
226 | 232 | | |
| |||
231 | 237 | | |
232 | 238 | | |
233 | 239 | | |
234 | | - | |
| 240 | + | |
235 | 241 | | |
236 | 242 | | |
237 | 243 | | |
| |||
413 | 419 | | |
414 | 420 | | |
415 | 421 | | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
416 | 436 | | |
417 | 437 | | |
418 | 438 | | |
| |||
Lines changed: 53 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
0 commit comments