Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Siddhesh2377/SplitButton

Repository files navigation

SplitButton Library

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. split_button

Features

  • 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.

Add to project

JitPack Release

allprojects {
 repositories {
 maven("https://jitpack.io")
 }
}
implementation("com.github.Siddhesh2377:SplitButton:<version>")

Usage

XML Example

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>

Dynamic Button Management

You can add or remove buttons dynamically:

Add a Button

val splitButton = findViewById<SplitButton>(R.id.splitButton)
splitButton.addNewButton("New Button")

Remove a Button

splitButton.removeViewAt(1) // Removes the button at index 1

Customization

Available Attributes

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.

Contributing

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.


License

This project is licensed under the MIT License. See the LICENSE file for more details.

Acknowledgements

This library is inspired by the Material Components Android Split Button and aims to bring a similar experience to stable Material3 implementations.

About

SplitButton is a re-creation of the Material3 Split Button, Do Star ⭐ my repo if you like

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

AltStyle によって変換されたページ (->オリジナル) /