Header.Builder
class Header.Builder
A builder of Header.
Summary
Public constructors |
|---|
Builder() |
Public functions |
|
|---|---|
Header.Builder |
addEndHeaderAction(headerAction: Action)Adds an |
Header |
build()Constructs the component defined by this builder. |
Header.Builder |
@ExperimentalCarApiSets the |
Header.Builder |
setStartHeaderAction(headerAction: Action)Sets the |
Header.Builder |
@ExperimentalCarApiSets the image that will be displayed at the start of the header after the |
Header.Builder |
@ExperimentalCarApiSets the subtitle of the component. |
Header.Builder |
@ExperimentalCarApiSets the subtitle of the component. |
Header.Builder |
Sets the title of the component, with support for multiple length variants. |
Header.Builder |
setTitle(title: CharSequence)Sets the title of the component. |
Public constructors
Public functions
addEndHeaderAction
fun addEndHeaderAction(headerAction: Action): Header.Builder
Adds an Action that will be displayed at the end of a header.
Note: End header action will show up differently inside and outside of map-based templates.
- In a Non-map screen (eg.
MessageTemplate), actions appear as is, just as the app provides. A background color is allowed on the primary action. - In a Map-based screen (eg. Setting Header in the ContentTemplate in a
MapWithContentTemplate) only actions with custom icons or standard actions will appear in the Header. The label will be stripped off each action if an app still provides that. Any tint on the icon will be disabled and default to neutral token. The background color on the primary action would also be removed.
build
fun build(): Header
Constructs the component defined by this builder.
Requirements
Either a start header Action or title must be set on the component.
| Throws | |
|---|---|
java.lang.IllegalStateException |
if neither a title nor start header |
java.lang.IllegalArgumentException |
if |
setBackground
@ExperimentalCarApi
@RequiresCarApi(value = 9)
fun setBackground(background: Background): Header.Builder
Sets the Background of the component.
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
setStartHeaderAction
fun setStartHeaderAction(headerAction: Action): Header.Builder
Sets the Action that will be displayed at the start of a header.
By default, a header will not have a start action.
Requirements
Only one ofAPP_ICON or BACK is supported as a start header Action.
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if |
java.lang.NullPointerException |
if |
setStartHeaderImage
@ExperimentalCarApi
@RequiresCarApi(value = 9)
fun setStartHeaderImage(startHeaderImage: CarIcon): Header.Builder
Sets the image that will be displayed at the start of the header after the setStartHeaderAction.
Only custom CarIcons are supported.
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
java.lang.IllegalArgumentException |
if |
setSubtitle
@ExperimentalCarApi
@RequiresCarApi(value = 9)
fun setSubtitle(subtitle: CarText): Header.Builder
Sets the subtitle of the component.
Support colors and icons.
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
java.lang.IllegalArgumentException |
if |
| See also | |
|---|---|
CarText |
setSubtitle
@ExperimentalCarApi
@RequiresCarApi(value = 9)
fun setSubtitle(subtitle: CharSequence): Header.Builder
Sets the subtitle of the component.
Support colors and icons.
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
java.lang.IllegalArgumentException |
if |
| See also | |
|---|---|
CarText |
setTitle
fun setTitle(title: CarText): Header.Builder
Sets the title of the component, with support for multiple length variants.
Only DistanceSpans and DurationSpans are supported in the input string.
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
java.lang.IllegalArgumentException |
if |
| See also | |
|---|---|
CarText |
setTitle
fun setTitle(title: CharSequence): Header.Builder
Sets the title of the component.
Only DistanceSpans and DurationSpans are supported in the input string.
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
java.lang.IllegalArgumentException |
if |
| See also | |
|---|---|
CarText |