Class TextStyleBuilder Stay organized with collections Save and categorize content based on your preferences.
Page Summary
TextStyleBuilder is used to create text styles.
It provides methods to set properties like bold, italic, underline, strikethrough, font family, font size, and foreground color.
The
build()method creates the final TextStyle object from the builder.Most methods return the TextStyleBuilder itself, allowing for method chaining.
A builder for text styles.
Methods
| Method | Return type | Brief description |
|---|---|---|
build() | Text | Creates a text style from this builder. |
set | Text | Sets whether or not the text is bold. |
set | Text | Sets the text font family, such as "Arial". |
set | Text | Sets the text font size in points. |
set | Text | Sets the text font color. |
set | Text | Sets the text font color. |
set | Text | Sets whether or not the text is italic. |
set | Text | Sets whether or not the text has strikethrough. |
set | Text | Sets whether or not the text is underlined. |
Detailed documentation
build()
setBold(bold)
Sets whether or not the text is bold.
Parameters
| Name | Type | Description |
|---|---|---|
bold | Boolean | Whether or not the text is bold. |
Return
Text — The builder for chaining.
setFontFamily(fontFamily)
Sets the text font family, such as "Arial".
Parameters
| Name | Type | Description |
|---|---|---|
font | String | The desired font family. |
Return
Text — The builder for chaining.
setFontSize(fontSize)
Sets the text font size in points.
Parameters
| Name | Type | Description |
|---|---|---|
font | Integer | The desired font size. |
Return
Text — The builder for chaining.
setForegroundColor(cssString)
Sets the text font color.
Parameters
| Name | Type | Description |
|---|---|---|
css | String | The desired font color in CSS notation (such as'#ffffff' or'white'). |
Return
Text — The builder for chaining.
setForegroundColorObject(color)
Sets the text font color.
Parameters
| Name | Type | Description |
|---|---|---|
color | Color | The desired font color. |
Return
Text — The builder for chaining.
setItalic(italic)
Sets whether or not the text is italic.
Parameters
| Name | Type | Description |
|---|---|---|
italic | Boolean | Whether or not the text is italic. |
Return
Text — The builder for chaining.
setStrikethrough(strikethrough)
Sets whether or not the text has strikethrough.
Parameters
| Name | Type | Description |
|---|---|---|
strikethrough | Boolean | Whether or not the text has strikethrough. |
Return
Text — The builder for chaining.
setUnderline(underline)
Sets whether or not the text is underlined.
Parameters
| Name | Type | Description |
|---|---|---|
underline | Boolean | Whether or not the text is underlined. |
Return
Text — The builder for chaining.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-11 UTC.