MaterialButtonGroup

A common container for a set of related MaterialButtons. The MaterialButtons in this group will be shown on a single line.

This layout currently only supports child views of type MaterialButton. Buttons can be added to this view group via XML, as follows:

<com.google.android.material.button.MaterialButtonGroup
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toggle_button_group"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <com.google.android.material.button.MaterialButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/button_label_private"/>
    <com.google.android.material.button.MaterialButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/button_label_team"/>
    <com.google.android.material.button.MaterialButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/button_label_everyone"/>
    <com.google.android.material.button.MaterialButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/button_label_custom"/>

</com.google.android.material.button.MaterialButtonGroup>

Buttons can also be added to this view group programmatically via the addView methods.

MaterialButtonGroup is a LinearLayout. Using android:layout_width="MATCH_PARENT" and removing android:insetBottom android:insetTop on the children is recommended if using VERTICAL.

For more information, see the component developer guidance and design guidelines.

Inheritors

Constructors

Link copied to clipboard
constructor(@NonNull context: Context)
constructor(@NonNull context: Context, @Nullable attrs: AttributeSet)
constructor(@NonNull context: Context, @Nullable attrs: AttributeSet, defStyleAttr: Int)

Types

Link copied to clipboard
Link copied to clipboard
The interface for the overflow mode attribute.
Link copied to clipboard
Class for common logic between this MaterialButtonGroup and the OverflowLinearLayout overflow features.

Properties

Link copied to clipboard
Link copied to clipboard
A value for overflowMode.
Link copied to clipboard
A value for overflowMode.
Link copied to clipboard
A value for overflowMode.
Link copied to clipboard
open var overflowMode: Int
Link copied to clipboard
@get:Px
open var spacing: Int

Functions

Link copied to clipboard
open fun addView(@NonNull child: View, index: Int, @Nullable params: ViewGroup.LayoutParams)
This override prohibits Views other than MaterialButton to be added.
Link copied to clipboard
Returns the original ShapeAppearanceModel for the MaterialButton child at the given index.
Link copied to clipboard
Returns the inner corner size of the group.
Link copied to clipboard
Returns the inner corner size state list of the group.
Link copied to clipboard
Returns the icon shown for the overflow button, if present.
Link copied to clipboard
Link copied to clipboard
open fun onViewRemoved(child: View)
Link copied to clipboard
open fun setEnabled(enabled: Boolean)
Enables this MaterialButtonGroup and all its MaterialButton children
Link copied to clipboard
open fun setInnerCornerSize(@NonNull cornerSize: CornerSize)
Sets the inner corner size of the group.
Link copied to clipboard
Sets the inner corner size state list of the group.
Link copied to clipboard
open fun setOrientation(orientation: Int)
Link copied to clipboard
Sets the icon to show for the overflow button.
Link copied to clipboard
open fun setOverflowButtonIconResource(@DrawableRes iconResourceId: Int)
Sets the icon to show for the overflow button.
Link copied to clipboard
open fun setShapeAppearance(@Nullable shapeAppearance: ShapeAppearanceModel)
Sets the ShapeAppearanceModel of the group.
Link copied to clipboard