Button.Builder
class Button.Builder
Builder class for Button.
Summary
Public constructors |
|---|
Builder(context: Context, clickable: ModifiersBuilders.Clickable)Creates a builder for the |
Public functions |
|
|---|---|
Button |
build()Constructs and returns |
Button.Builder |
setButtonColors(buttonColors: ButtonColors)Sets the colors for the |
Button.Builder |
setContentDescription(contentDescription: CharSequence)Sets the static content description for the |
Button.Builder |
setContentDescription(contentDescription: TypeBuilders.StringProp)Sets the content description for the |
Button.Builder |
Sets the custom content for this Button. |
Button.Builder |
setIconContent(imageResourceId: String)Sets the content of this Button to be the given icon with the default size that is half of the set size of the button. |
Button.Builder |
setIconContent(imageResourceId: String, size: DimensionBuilders.DpProp)Sets the content of this Button to be the given icon with the given size. |
Button.Builder |
setImageContent(imageResourceId: String)Sets the content of this Button to be the given image, i.e. contacts photo. |
Button.Builder |
setSize(size: DimensionBuilders.DpProp)Sets the size for the |
Button.Builder |
Sets the size for the |
Button.Builder |
setTextContent(text: String)Sets the content of this Button to be the given text with the default font for the set size (for the |
Button.Builder |
setTextContent(text: String, typographyName: Int)Sets the content of this Button to be the given text with the given font. |
Public constructors
Builder
Builder(context: Context, clickable: ModifiersBuilders.Clickable)
Creates a builder for the Button from the given content. Custom content should be later set with one of the following setIconContent, setIconContent, setTextContent, setTextContent or setImageContent.
| Parameters | |
|---|---|
context: Context |
The application's context. |
clickable: ModifiersBuilders.Clickable |
Associated |
Public functions
build
fun build(): Button
Constructs and returns Button with the provided field and look.
setButtonColors
fun setButtonColors(buttonColors: ButtonColors): Button.Builder
Sets the colors for the Button. If not set, PRIMARY_COLORS will be used.
Note: The content color will be ignored (and won't be returned by the getter) if the Button content is an image.
setContentDescription
fun setContentDescription(contentDescription: CharSequence): Button.Builder
Sets the static content description for the Button. It is highly recommended to provide this for button containing icon or image.
setContentDescription
fun setContentDescription(contentDescription: TypeBuilders.StringProp): Button.Builder
Sets the content description for the Button. It is highly recommended to provide this for button containing icon or image.
While this field is statically accessible from 1.0, it's only bindable since version 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).
setCustomContent
fun setCustomContent(content: LayoutElementBuilders.LayoutElement): Button.Builder
Sets the custom content for this Button. Any previously added content will be overridden.
setIconContent
fun setIconContent(imageResourceId: String): Button.Builder
Sets the content of this Button to be the given icon with the default size that is half of the set size of the button. Any previously added content will be overridden. Provided icon will be tinted to the given content color from ButtonColors. This icon should be image with chosen alpha channel and not an actual image.
setIconContent
fun setIconContent(imageResourceId: String, size: DimensionBuilders.DpProp): Button.Builder
Sets the content of this Button to be the given icon with the given size. Any previously added content will be overridden. Provided icon will be tinted to the given content color from ButtonColors and with the given size. This icon should be image with chosen alpha channel and not an actual image.
setImageContent
fun setImageContent(imageResourceId: String): Button.Builder
Sets the content of this Button to be the given image, i.e. contacts photo. Any previously added content will be overridden.
setSize
fun setSize(size: DimensionBuilders.DpProp): Button.Builder
Sets the size for the Button. Strongly recommended values are DEFAULT_SIZE, LARGE_SIZE and EXTRA_LARGE_SIZE. If not set, DEFAULT_SIZE will be used.
setSize
fun setSize(size: @Dimension(unit = 0) Float): Button.Builder
Sets the size for the Button. Strongly recommended values are DEFAULT_SIZE, LARGE_SIZE and EXTRA_LARGE_SIZE. If not set, DEFAULT_SIZE will be used.
setTextContent
fun setTextContent(text: String): Button.Builder
Sets the content of this Button to be the given text with the default font for the set size (for the DEFAULT_SIZE, LARGE_SIZE and EXTRA_LARGE_SIZE is TYPOGRAPHY_TITLE2, TYPOGRAPHY_TITLE1 and TYPOGRAPHY_DISPLAY3 respectively). Any previously added content will be overridden. Text should contain no more than 3 characters, otherwise it will overflow from the edges.
setTextContent
fun setTextContent(text: String, typographyName: Int): Button.Builder
Sets the content of this Button to be the given text with the given font. If you need more font related customization, consider using setCustomContent with Text component. Any previously added content will be overridden. Text should contain no more than 3 characters, otherwise it will overflow from the edges.