Class StyledText

StyledText

Text element with styles such as bold, italic and color.

Only available for Google Workspace add-ons that extend Google Workspace Studio.

Sample usage:

conststyledText=AddOnsResponseService.newStyledText()
.setText("Styled Text!")
.addStyle(AddOnsResponseService.TextStyle.ITALIC)
.addStyle(AddOnsResponseService.TextStyle.UNDERLINE)
.setFontWeight(AddOnsResponseService.FontWeight.BOLD)
.setColor(
AddOnsResponseService.newColor()
.setRed(0.1)
.setBlue(0.3)
.setGreen(0.1)
.setAlpha(0.78)
);

Methods

MethodReturn typeBrief description
addStyle(style) StyledText Sets the style of the styled text, can apply multiple styles to a single styled text.
setColor(color) StyledText Sets the color of the styled text.
setFontWeight(fontWeight) StyledText Sets the font weight of the styled text.
setText(text) StyledText Sets the main content of the styled text.

Detailed documentation

addStyle(style)

Sets the style of the styled text, can apply multiple styles to a single styled text.

Parameters

NameTypeDescription
styleTextStyle The TextStyle of the styled text.

Return

StyledText — This styled text object, for chaining.


setColor(color)

Sets the color of the styled text.

Parameters

NameTypeDescription
colorColor The Color of the styled text.

Return

StyledText — This styled text object, for chaining.


setFontWeight(fontWeight)

Sets the font weight of the styled text.

Parameters

NameTypeDescription
fontWeightFontWeight The FontWeight of the styled text.

Return

StyledText — This styled text object, for chaining.


setText(text)

Sets the main content of the styled text.

Parameters

NameTypeDescription
textStringThe text message in the styled text.

Return

StyledText — This styled text object, for chaining.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026年04月13日 UTC.