MaterialSplitButton


Kotlin |Java

public class MaterialSplitButton extends MaterialButtonGroup 


A container for two MaterialButton s that together create a split button. The MaterialButton 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 MaterialButton s.

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 MaterialButton has an animated vector drawable as an icon.

static final int

A value for overflowMode.

static final int

A value for overflowMode.

static final int

A value for overflowMode.

Inherited Constants

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

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

ShapeAppearanceModel

Returns the original ShapeAppearanceModel for the MaterialButton child at the given index.

CornerSize

Returns the inner corner size of the group.

Drawable

Returns the icon shown for the overflow button, if present.

int

Returns the overflow mode.

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
setOverflowButtonIcon(Drawable icon)

Sets the icon to show for the overflow button.

void
setOverflowButtonIconResource(int iconResourceId)

Sets the icon to show for the overflow button.

void
setOverflowMode(int overflowMode)

Sets the overflow mode.

void

Sets the ShapeAppearanceModel of the group.

void
setSpacing(int spacing)

Sets the spacing between each button in the group.

Inherited methods

From com.google.android.material.button.MaterialButtonGroup

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 MaterialButton has an animated vector drawable as an icon. It also makes updates to the add button shape and margins.

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2026年05月14日 UTC.