SplitButton is a re-creation of the Material3 Split Button, inspired by the Material Components Android Button documentation. This library provides a highly customizable implementation of the Material3 Split Button, which is currently not included in the stable Material library.
- Fully customizable split button.
- Supports dynamic addition and removal of buttons.
- Implements Material Design principles.
- Easy to integrate into any Android project.
- Built-in fade-in and fade-out animations for adding and removing buttons dynamically.
allprojects {
repositories {
maven("https://jitpack.io")
}
}
implementation("com.github.Siddhesh2377:SplitButton:<version>")
Include the SplitButton in your layout XML:
<com.dark.splitbutton.SplitButton
android:id="@+id/splitButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:childBackgroundColor="@color/primary"
app:childTextColor="@color/onPrimary"
app:edgeCorner="16dp"
app:childCorner="8dp"
app:childSpacing="8dp">
<com.google.android.material.button.MaterialButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="First" />
<com.google.android.material.button.MaterialButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Middle" />
<com.google.android.material.button.MaterialButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Last" />
</com.dark.splitbutton.SplitButton>
You can add or remove buttons dynamically:
val splitButton = findViewById<SplitButton>(R.id.splitButton)
splitButton.addNewButton("New Button")
splitButton.removeViewAt(1) // Removes the button at index 1
Attribute | Format | Description |
---|---|---|
childBackgroundColor |
color |
Background color of the child buttons. |
childTextColor |
color |
Text color of the child buttons. |
edgeCorner |
float |
Corner radius for the first and last buttons. |
childCorner |
float |
Corner radius for the middle buttons. |
childSpacing |
dimension |
Spacing between the child buttons. |
Contributions are welcome! If you find any issues or want to improve this library, feel free to open a pull request or issue on GitHub.
This library is inspired by the Material Components Android Split Button and aims to bring a similar experience to stable Material3 implementations.