A dual-function menu button that offers a default action as well as the possibility of choosing a different action by selecting from a set of alternatives.

Overview

SplitButton

Jit

A dual-function menu button that offers a default action as well as the possibility of choosing a different action by selecting from a set of alternatives.

Setup

Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        //...omitted for brevity
        maven { url 'https://jitpack.io' }
    }
}

Add the dependency

dependencies {
   implementation "com.github.kojofosu:SplitButton:$latest_release"
}

Demo

demo

Usage

Sample implementation here

Split Button

  • Add SplitButton to your xml layout.
">
    <com.mcdev.splitbuttonlibrary.SplitButton
        android:id="@+id/split_btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

Initialize and customise split button

    var splitBtn: SplitButton = findViewById(R.id.split_btn)
    
    splitBtn.setTextColor(R.color.black)
    splitBtn.setIconColor(android.R.color.white)
    splitBtn.setBgColor(android.R.color.holo_orange_light)
    splitBtn.setMenuItems(R.menu.split_menu, R.style.PopMen)

Button listener

            splitBtn.setOnButtonClickListener(object : OnButtonClickListener {
                override fun onClick(itemId: Int, itemTitle: String?) {
                    Log.d("TAG", "onClick: id :$itemId")
                    Log.d("TAG", "onClick: title :$itemTitle")
                    if (itemId == R.id.send) {

                        Toast.makeText(this@MainActivity, "Send", Toast.LENGTH_SHORT).show()
                        Log.d("TAG", "onClick: send  ")
                    }else if (itemId == R.id.sfl) {

                        Toast.makeText(this@MainActivity, "Save for later", Toast.LENGTH_SHORT).show()
                        Log.d("TAG", "onClick: bookmark ")
                    } else if (itemId == R.id.draft) {
                        Toast.makeText(this@MainActivity, "Draft", Toast.LENGTH_SHORT).show()
                    }
                }
            })

Add menu items. Create menu list and place it in src/main/res/menu/ directory.

">
    <menu xmlns:android="http://schemas.android.com/apk/res/android">
        <item
            android:id="@+id/send"
            android:icon="@drawable/ic_paper_plane"
            android:title="Send"/>
    
        <item
            android:id="@+id/sfl"
            android:icon="@drawable/ic_calendar"
            android:title="Schedule"/>
    
        <item
            android:id="@+id/draft"
            android:icon="@drawable/ic_bookmark"
            android:title="Draft"/>
    menu>

Style menu items

  • To style menu items to change background color etc
@android:color/black @android:color/holo_orange_light 30dp 30dp 30dp ">
    <style name="PopMen" parent="Widget.AppCompat.PopupMenu.Overflow">
        
        <item name="android:textColor">@android:color/blackitem> 
        
        <item name="popupMenuBackground">@android:color/holo_orange_lightitem>

        <item name="android:radius">30dpitem>
        <item name="cardCornerRadius">30dpitem>
        <item name="cornerRadius">30dpitem>
    style>

Licensed under the Apache-2.0 License

You might also like...
A menu which can ... BOOM! - Android
A menu which can ... BOOM! - Android

BoomMenu 2.0.0 Comes Finally Approximately 8 months ago, I got an inspiration to creating something that can boom and show menu, which I named it Boom

:fire: The powerful and easiest way to implement modern material popup menu.
:fire: The powerful and easiest way to implement modern material popup menu.

PowerMenu 🔥 The powerful and easiest way to implement modern material popup menu. PowerMenu can be fully customized and used for popup dialogs. Downl

** A slide-out menu implementation, which allows users to navigate between views in your app.

MenuDrawer A slide-out menu implementation, which allows users to navigate between views in your app. Most commonly the menu is revealed by either dra

Android Satellite Menu
Android Satellite Menu

#Satellite Menu 'Path' has a very attractive menu sitting on the left bottom corner of the screen. Satellite Menu is the open version of this menu. Fo

An android custom view which looks like the menu in Path 2.0 (for iOS).

ArcMenu & RayMenu ArcMenu An android custom view which looks like the menu in Path 2.0 (for iOS). RayMenu About The user experience in Path 2.0 (for i

Tap Bar Menu
Tap Bar Menu

TapBar Menu Simple library that helps creating a "Tap Bar" menu layout. Demo 1: https://youtu.be/DjY0cTWWtao Demo 2: https://youtu.be/dWuPMN6WTOY Inst

(UNMAINTAINED) An implemention of  Filter Menu concept for android
(UNMAINTAINED) An implemention of Filter Menu concept for android

FilterMenu This is a library project with a custom view that implements concept of Filter Menu(https://dribbble.com/shots/1956586-Filter-Menu) made by

Navigation menu for Android (based off Google+ app)
Navigation menu for Android (based off Google+ app)

RibbonMenu Navigation menu for Android (based on Google+ app). Usage Menus are created in xml as normal, adding text and an icon. In the layout you wa

Simple and easy to use circular menu widget for Android.
Simple and easy to use circular menu widget for Android.

Deprecated This project is no longer maintained. No new issues or pull requests will be accepted. You can still use the source or fork the project to

Releases(v1.1)
  • v1.1(Oct 18, 2021)

    What's Changed

    • Added Setting menu items with arraylist by @xtanion in https://github.com/kojofosu/SplitButton/pull/3
    • Update README.md by @suyalamritanshu in https://github.com/kojofosu/SplitButton/pull/2

    New Contributors

    • @xtanion made their first contribution in https://github.com/kojofosu/SplitButton/pull/3
    • @suyalamritanshu made their first contribution in https://github.com/kojofosu/SplitButton/pull/2

    Full Changelog: https://github.com/kojofosu/SplitButton/compare/v1.0...v1.1

    Source code(tar.gz)
    Source code(zip)
Owner
Kojo Fosu Bempa Edue
Make it nice, and make it work!
Kojo Fosu Bempa Edue
🚀 A very customizable library that allows you to present menu items (from menu resource and/or other sources) to users as a bottom sheet.

SlidingUpMenu A library that allows you to present menu items (from menu resource and/or other sources) to users as a bottom sheet. Gradle Dependency

Rasheed Sulayman 26 Jul 17, 2022
Classic Power Menu is a Power Menu Replacement for Android 11+

Classic Power Menu is a Power Menu Replacement for Android 11+, with the main aim being restoring power menu options (Device Controls & Quick Access Wallet) on Android 12.

Kieron Quinn 385 Dec 31, 2022
Android library that provides the floating action button to sheet transition from Google's Material Design.

MaterialSheetFab Library that implements the floating action button to sheet transition from Google's Material Design documentation. It can be used wi

Gordon Wong 1.6k Dec 13, 2022
A simple Floating Action Button that shows an anchored Navigation View

Floating Navigation View A simple Floating Action Button that shows an anchored Navigation View and was inspired by Menu Material Fixed created by Tom

André Mion 1.3k Dec 29, 2022
An Android Library that allows users to pull down a menu and select different actions. It can be implemented inside ScrollView, GridView, ListView.

AndroidPullMenu AndroidPullMenu is an Open Source Android library that allows developers to easily create applications with pull menu. The aim of this

Armando TBA 181 Nov 29, 2022
an animated circular menu for Android

CircularFloatingActionMenu An animated, customizable circular floating menu for Android, inspired by Path app. Getting Started Requirements API >= 15

OÄŸuz Bilgener 2.7k Dec 24, 2022
Side menu with some categories to choose.

Side Menu Side menu with some categories to choose. Check this project on dribbble. Check this project on Behance. God bless Ukraine! Sample Sample &

Yalantis 5.2k Dec 23, 2022
You can easily add awesome animated context menu to your app.

ContextMenu You can easily add awesome animated context menu to your app. Check this project on dribbble Check this project on Behance Usage: For a wo

Yalantis 3.8k Dec 28, 2022
imitate Tumblr's menu, dragging animations look like a snake

android-snake-menu imitate Tumblr's menu, dragging animations look like a snake unexpected episode I found another repository some time ago which impl

stone 586 Nov 10, 2022