-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2/n Nested Text textAlignVertical (Android) - adding textAlignVertical prop to NestedText #35704
Conversation
P type task |
Base commit: bf03e86 |
Base commit: 4d8ba7b |
P type task |
PR build artifact for 7d147de is ready. |
PR build artifact for 7d147de is ready. |
…figs in TtsSpan, because the value mVerticalAlign is set in TextAttributesProps.java, but not in MapBuffer. facebook#35704 (comment)
This comment was marked as duplicate.
This comment was marked as duplicate.
P type task |
PR build artifact for fdeb37c is ready. |
PR build artifact for fdeb37c is ready. |
P type task |
PR build artifact for 5565bc1 is ready. |
PR build artifact for 5565bc1 is ready. |
P type task |
…h the updated TextView height facebook#35704 (comment)
PR build artifact for 9de465b is ready. |
PR build artifact for 9de465b is ready. |
|
} | ||
} | ||
for (CustomStyleSpan span : customStyleSpans) { | ||
span.updateSpan(highestLineHeight, highestFontSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://developer.android.com/develop/ui/views/text-and-emoji/spans#best-practices
Calling view.setText(update)
before updating the span. Result: text correctly aligns to the top or the bottom, the parent text vertical align does not change.
https://www.icloud.com/iclouddrive/0e3YRsM1KKEs0SXo0nvkEy9OQ#call_set_text_before_mutation
Calling view.setText(update)
after updating the span. Result: text does not align correctly, The regression is caused by the change in the parent text vertical align.
https://www.icloud.com/iclouddrive/087kw0jNMTAFnT5pJ-mPHXzaQ#call_set_text_after_mutation
The logic is required to align spans correctly. The functionality works without issues.
P type task |
If you need to change only an internal attribute of a mutable span, such as the bullet color in a custom bullet span, you can avoid the overhead from calling setText() multiple times by keeping a reference to the span as it's created. When you need to modify the span, you can modify the reference and then call either invalidate() or requestLayout() on the TextView, depending on the type of attribute that you changed.
P type task |
b42f981
to
dbeecaa
Compare
This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This PR was closed because it has been stalled for 7 days with no activity. |
I deleted the branch for mistake |
Summary
Requires merging 1/n Nested Text textAlignVertical (Android) - Adding CustomStyleSpan API to align nested text vertically PR #35949.
2/n of a series of pull requests (Nested Text textAlignVertical):
CSS - vertical-align with spans
The CSS vertical-align property vertically aligns text on a character level
Code example CSS vertical-align
#30375 (comment)
https://jsfiddle.net/2duoLyq4/14/
Android - explanation of the corresponding Span Android APIs
MetricAffectingSpan allows to vertically align text (group of characters, not paragraphs divided by
\n
) by changing the TextPaint baseline of a span.Text is represented as TextView on Android, Nested Text is represented as Spans.
https://developer.android.com/develop/ui/views/text-and-emoji/spans
https://developer.android.com/develop/ui/views/text-and-emoji/spans#span-types
They consist of four types:
Android does not support CSS vertical-align on character-level
An example of similar functionality on Android is the AlignmentSpan.
A paragraph is a text separated by
\n
(new line). The AlignmentSpan changes the horizontal alignment of the paragraph.https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/text/Layout.java;l=494-500;drc=caabd536e8fea82b888902f359b33e637267966c;bpv=1;bpt=1?q=ALIGN_OPPOSITE&ss=android%2Fplatform%2Fsuperproject
Details on how the Layout.java API draws text with the AlignmentSpan.
#30375 (comment).
ALIGN_CENTER
,ALIGN_OPPOSITE
orALIGN_NORMAL
.fixes #30375 #30375 (comment)
Changelog
[ANDROID] [ADDED] - 2/n Nested Text textAlignVertical (Android) - adding textAlignVertical prop to NestedText
Test Plan
#35704 (comment)
#35704 (comment)
#35704 (comment)
Previous Tests
#35704 (comment)
#35704 (comment) #35704 (comment)