MaterialSplitButton

A container for two MaterialButtons that together create a split button. The s 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.MaterialSplitButton
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/split_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/split_button_label"
        app:icon="@drawable/ic_edit_vd_theme_24dp"
        app:iconGravity="start"/>
    <Button
       style="?attr/materialSplitButtonIconFilledStyle"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:contentDescription="@string/split_button_label_chevron"
       app:icon="@drawable/m3_split_button_chevron_avd"/>

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

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

MaterialSplitButton is a MaterialButtonGroup with only two MaterialButtons.

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

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)

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 where the leading MaterialButton has either an icon and/or a label and the trailing has an animated vector drawable as an icon.