MaterialSplitButton

public class MaterialSplitButton extends MaterialButtonGroup


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/materialIconSplitButtonFilledStyle"
       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.

Summary

Public constructors

MaterialSplitButton(Context context)
MaterialSplitButton(Context context, AttributeSet attrs)
MaterialSplitButton(
    Context context,
    AttributeSet attrs,
    int defStyleAttr
)

Public methods

void
addView(View child, int index, LayoutParams params)

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.

Inherited methods

From com.google.android.material.button.MaterialButtonGroup
void
dispatchDraw(Canvas canvas)
int
getChildDrawingOrder(int childCount, int i)

We keep track of which views are pressed and checked to draw them last.

CornerSize

Returns the inner corner size of the group.

ShapeAppearanceModel

Returns the ShapeAppearanceModel of the group.

int

Returns the spacing (in pixels) between each button in the group.

void
onLayout(boolean changed, int l, int t, int r, int b)
void
onMeasure(int widthMeasureSpec, int heightMeasureSpec)
void
onViewRemoved(View child)
void
setEnabled(boolean enabled)

Enables this MaterialButtonGroup and all its MaterialButton children

void

Sets the inner corner size of the group.

void
setOrientation(int orientation)
void

Sets the ShapeAppearanceModel of the group.

void
setSpacing(int spacing)

Sets the spacing between each button in the group.

Public constructors

MaterialSplitButton

public MaterialSplitButton(Context context)

MaterialSplitButton

public MaterialSplitButton(Context context, AttributeSet attrs)

MaterialSplitButton

public MaterialSplitButton(
    Context context,
    AttributeSet attrs,
    int defStyleAttr
)

Public methods

addView

public void addView(View child, int index, LayoutParams params)

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. It also makes updates to the add button shape and margins.