Tab.Builder

public final class Tab.Builder


A builder of Tab.

Summary

Public constructors

Returns an empty Tab.Builder instance.

Creates a new Builder, populated from the input Tab

Public methods

@NonNull Tab

Constructs the Tab defined by this builder.

@NonNull Tab.Builder

Sets the content ID of the tab.

@NonNull Tab.Builder

Sets the icon to display in the tab.

@NonNull Tab.Builder

Sets the title of the tab.

Public constructors

Builder

Added in 1.3.0
public Builder()

Returns an empty Tab.Builder instance.

Builder

Added in 1.4.0-rc02
public Builder(@NonNull Tab tab)

Creates a new Builder, populated from the input Tab

Public methods

build

Added in 1.3.0
public @NonNull Tab build()

Constructs the Tab defined by this builder.

Throws
java.lang.IllegalStateException

if the tab's title, icon or content ID is not set.

setContentId

Added in 1.3.0
public @NonNull Tab.Builder setContentId(@NonNull String contentId)

Sets the content ID of the tab.

Throws
java.lang.NullPointerException

if contentId is null

java.lang.IllegalArgumentException

if contentId is empty

setIcon

Added in 1.3.0
public @NonNull Tab.Builder setIcon(@NonNull CarIcon icon)

Sets the icon to display in the tab.

Icon Sizing Guidance To minimize scaling artifacts across a wide range of car screens, apps should provide icons targeting a 36 x 36 dp bounding box. If the icon exceeds this maximum size in either one of the dimensions, it will be scaled down to be centered inside the bounding box while preserving its aspect ratio.

See CarIcon for more details related to providing icon and image resources that work with different car screen pixel densities.

Throws
java.lang.NullPointerException

if icon is null

setTitle

Added in 1.3.0
public @NonNull Tab.Builder setTitle(@NonNull CharSequence title)

Sets the title of the tab.

Only DistanceSpans and DurationSpans are supported in the input string.

Throws
java.lang.NullPointerException

if title is null

java.lang.IllegalArgumentException

if title is empty, of if it contains unsupported spans