-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Changes from all commits
c683779
6716e0f
7d147de
7914cfd
fdeb37c
5565bc1
9de465b
7ab97c2
0f7d69d
59fe775
5017156
f75e899
ba18167
9a7ad5b
61e5089
582faa4
8573fd5
28608f1
957c784
ba5223b
47ddd11
ce2b8eb
87d205f
7ac7a9a
bec2e1d
2ff855b
ee66a98
b3efb82
395bbd2
af8a7e9
e363196
dbe25d3
812d406
4f6095e
49abefd
469c6d7
003ab18
17c70ad
7fca70c
6c4e19b
a2e3d4e
5b9c505
72f4726
331d945
e85bbe7
1230e06
c139885
5879630
c4d82d3
eb0b424
112eeee
5f76bff
a770ea8
95324ec
e59529d
224c58a
c9278d9
94d644e
0e20043
d281638
46e3815
c91e24d
89b95dc
0bf75e7
dbeecaa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,38 @@ public void updateExtraData(ReactTextView view, Object extraData) { | |
ReactAccessibilityDelegate.resetDelegate( | ||
view, view.isFocusable(), view.getImportantForAccessibility()); | ||
} | ||
|
||
CustomLineHeightSpan[] customLineHeightSpans = | ||
spannable.getSpans(0, spannable.length(), CustomLineHeightSpan.class); | ||
CustomStyleSpan[] customStyleSpans = | ||
spannable.getSpans(0, spannable.length(), CustomStyleSpan.class); | ||
if (customLineHeightSpans.length > 0 && customStyleSpans.length > 0) { | ||
int highestLineHeight = 0; | ||
for (CustomLineHeightSpan span : customLineHeightSpans) { | ||
if (highestLineHeight == 0 || span.getLineHeight() > highestLineHeight) { | ||
highestLineHeight = span.getLineHeight(); | ||
} | ||
} | ||
|
||
int highestFontSize = 0; | ||
if (highestLineHeight != 0) { | ||
for (CustomStyleSpan span : customStyleSpans) { | ||
if (highestFontSize == 0 || span.getSize() > highestFontSize) { | ||
highestFontSize = span.getSize(); | ||
} | ||
} | ||
for (CustomStyleSpan span : customStyleSpans) { | ||
/* | ||
* https://developer.android.com/develop/ui/views/text-and-emoji/spans#change-internal-attributes | ||
* Changes the internal span 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. | ||
*/ | ||
span.updateSpan(highestLineHeight, highestFontSize); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Calling The logic is required to align spans correctly. The functionality works without issues. |
||
} | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
|
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.