TextViewStyle.Builder

public final class TextViewStyle.Builder


Builder for the TextViewStyle.

Summary

Protected fields

final @NonNull Bundle

Public constructors

Public methods

@NonNull TextViewStyle

Returns a subclass of BundledStyle built by this builder.

@NonNull B

Sets the background.

@NonNull B

Sets the background color, it will always override the setBackground, regardless of which set method is call first.

@NonNull B
setLayoutMargin(int start, int top, int end, int bottom)

Sets the layout margin through the view's layout param.

@NonNull B
setPadding(int start, int top, int end, int bottom)

Sets the padding.

@NonNull TextViewStyle.Builder
setTextColor(@ColorInt int textColor)

Specifies the text color.

@NonNull TextViewStyle.Builder
setTextSize(float textSize)

Specifies the text size, in sp.

@NonNull TextViewStyle.Builder
setTextSize(int unit, float size)

Specifies the text size in the provided unit.

@NonNull TextViewStyle.Builder
setTypeface(@NonNull String fontFamily, int fontStyle)

Specifies the text font family and style.

Protected fields

mBundle

protected final @NonNull Bundle mBundle

Public constructors

Builder

Added in 1.1.0
public Builder()

Public methods

build

Added in 1.1.0
public @NonNull TextViewStyle build()

Returns a subclass of BundledStyle built by this builder.

setBackground

Added in 1.1.0
public @NonNullsetBackground(@NonNull Icon icon)

Sets the background.

Parameters
@NonNull Icon icon

The icon to use as the background

setBackgroundColor

Added in 1.1.0
public @NonNullsetBackgroundColor(@ColorInt int color)

Sets the background color, it will always override the setBackground, regardless of which set method is call first.

Parameters
@ColorInt int color

the color of the background

setLayoutMargin

Added in 1.1.0
public @NonNullsetLayoutMargin(int start, int top, int end, int bottom)

Sets the layout margin through the view's layout param.

Note that the method takes start/end rather than left/right, respecting the layout direction.

Parameters
int start

the start margin size

int top

the top margin size

int end

the end margin size

int bottom

the bottom margin size

setPadding

Added in 1.1.0
public @NonNullsetPadding(int start, int top, int end, int bottom)

Sets the padding.

Note that the method takes start/end rather than left/right, respecting the layout direction.

Parameters
int start

the start padding in pixels

int top

the top padding in pixels

int end

the end padding in pixels

int bottom

the bottom padding in pixels

See also
setPadding

setTextColor

Added in 1.1.0
public @NonNull TextViewStyle.Builder setTextColor(@ColorInt int textColor)

Specifies the text color.

Parameters
@ColorInt int textColor

A color value in the form 0xAARRGGBB.

See also
setTextColor

setTextSize

Added in 1.1.0
public @NonNull TextViewStyle.Builder setTextSize(float textSize)

Specifies the text size, in sp.

Parameters
float textSize

The scaled pixel size.

See also
setTextSize

setTextSize

Added in 1.1.0
public @NonNull TextViewStyle.Builder setTextSize(int unit, float size)

Specifies the text size in the provided unit.

Parameters
int unit

The desired dimension unit.

float size

The device independent pixel size.

See also
setTextSize

setTypeface

Added in 1.1.0
public @NonNull TextViewStyle.Builder setTypeface(@NonNull String fontFamily, int fontStyle)

Specifies the text font family and style. If the font family can not be found/loaded from the renderer process, it may fallback to the default system font.

Parameters
@NonNull String fontFamily

the font family for the type face

int fontStyle

the style for the type face.

See also
create
setTypeface