All Projects → zawadz88 → Materialpopupmenu

zawadz88 / Materialpopupmenu

Licence: apache-2.0
Shows Material popup menus grouped in sections & more

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Materialpopupmenu

Materialspinner
A spinner view for Android
Stars: ✭ 1,173 (+106.88%)
Mutual labels:  material-design, popup-window
Quill
👻 [MOVED TO https://github.com/TryGhost/Ghost-Android] The beautiful Android app for your Ghost blog.
Stars: ✭ 552 (-2.65%)
Mutual labels:  material-design
Iconfontcppheaders
C, C++ headers and C# classes for icon fonts: Font Awesome, Fork Awesome, Material Design, Kenney game icons and Fontaudio
Stars: ✭ 509 (-10.23%)
Mutual labels:  material-design
Awaker
article app for android
Stars: ✭ 526 (-7.23%)
Mutual labels:  material-design
Mnml
📹 A minimal, beautiful screen recorder for Android.
Stars: ✭ 514 (-9.35%)
Mutual labels:  material-design
Folding Cell Android
📃 FoldingCell is a material design expanding content cell inspired by folding paper material made by @Ramotion
Stars: ✭ 4,859 (+756.97%)
Mutual labels:  material-design
Mcg
Material Design Palette/Theme Generator - AngularJS, React, Ember, Vue, Android, Flutter & More!
Stars: ✭ 507 (-10.58%)
Mutual labels:  material-design
Grocery App
Flutter Grocery Shopping App (Mobile App, Web App) - Want to develop similar solutions for your business? Connect with us - [email protected] Or just submit an inquiry we will connect with you within 24 hours - https://forms.gle/L9EBUnSasYcUAn8Q9
Stars: ✭ 563 (-0.71%)
Mutual labels:  material-design
Needs
🌂 An easy way to implement modern permission instructions popup.
Stars: ✭ 546 (-3.7%)
Mutual labels:  popup-window
Android Iconics
Android-Iconics - Use any icon font, or vector (.svg) as drawable in your application.
Stars: ✭ 4,916 (+767.02%)
Mutual labels:  material-design
React Native Material Kit
Bringing Material Design to React Native
Stars: ✭ 4,838 (+753.26%)
Mutual labels:  material-design
Flutter deer
🦌 Flutter 练习项目(包括集成测试、可访问性测试)。内含完整UI设计图,更贴近真实项目的练习。Flutter practice project. Includes a complete UI design and exercises that are closer to real projects.
Stars: ✭ 5,725 (+909.7%)
Mutual labels:  popup-window
Light
🍭 The usual Snackbar, but elegant
Stars: ✭ 542 (-4.41%)
Mutual labels:  material-design
Material Viewpagerindicator
Dot-based Android ViewPager indicator with Material Design animations.
Stars: ✭ 511 (-9.88%)
Mutual labels:  material-design
Taptargetview
An implementation of tap targets from the Material Design guidelines for feature discovery.
Stars: ✭ 5,114 (+801.94%)
Mutual labels:  material-design
Script Server
Web UI for your scripts with execution management
Stars: ✭ 506 (-10.76%)
Mutual labels:  material-design
Hexo Theme One
hexo单页面炫酷主题
Stars: ✭ 522 (-7.94%)
Mutual labels:  material-design
Remindly
Remindly is a simple and user friendly Android application to create reminders.
Stars: ✭ 535 (-5.64%)
Mutual labels:  material-design
Changedetection
Automatically track websites changes on Android in background.
Stars: ✭ 563 (-0.71%)
Mutual labels:  material-design
Angular2 Mdl
Angular 2, 4, 5, 6, 7, 8, 9, 10, 11 components, directives and styles based on material design lite (npm: @angular-mdl/core)
Stars: ✭ 562 (-0.88%)
Mutual labels:  material-design

Material Popup Menu GitHubActions

This library allows to create simple popup menus programmatically with a nice type-safe builder syntax in Kotlin. Menus can be divided into separate sections with optional headers and contain icons.

  

Download (from JCenter)

implementation 'com.github.zawadz88.materialpopupmenu:material-popup-menu:4.1.0'

Getting started

To create a popup menu with a single section from an anchor view:

    fun onSingleSectionWithIconsClicked(view: View) {
        val popupMenu = popupMenu {
            section {
                item {
                    label = "Copy"
                    icon = R.drawable.abc_ic_menu_copy_mtrl_am_alpha //optional
                    callback = { //optional
                        Toast.makeText(this@LightActivity, "Copied!", Toast.LENGTH_SHORT).show()
                    }
                }
                item {
                    labelRes = R.string.label_paste
                    iconDrawable = ContextCompat.getDrawable(this@LightActivity, R.drawable.abc_ic_menu_paste_mtrl_am_alpha) //optional
                    callback = { //optional
                        Toast.makeText(this@LightActivity, "Text pasted!", Toast.LENGTH_SHORT).show()
                    }
                }
                item {
                    label = "Select all"
                    icon = R.drawable.abc_ic_menu_selectall_mtrl_alpha //optional
                }
            }
        }

        popupMenu.show(this@LightActivity, view)
    }

To create a popup menu with 2 sections and a section title in the second one:

    fun onSingleSectionWithIconsClicked(view: View) {
        val popupMenu = popupMenu {
            section {
                item {
                    label = "Copy"
                    icon = R.drawable.abc_ic_menu_copy_mtrl_am_alpha
                    callback = {
                        Toast.makeText(this@LightActivity, "Copied!", Toast.LENGTH_SHORT).show()
                    }
                }
                item {
                    labelRes = R.string.label_paste
                    icon = R.drawable.abc_ic_menu_paste_mtrl_am_alpha
                    callback = {
                        Toast.makeText(this@LightActivity, "Text pasted!", Toast.LENGTH_SHORT).show()
                    }
                }
            }
            section {
                title = "Other"
                item {
                    label = "Select all"
                    icon = R.drawable.abc_ic_menu_selectall_mtrl_alpha
                }
            }
        }

        popupMenu.show(this@LightActivity, view)
    }

Supported features

  • Showing popup menus with a builder pattern
  • Separator between popup menu sections
  • Section headers
  • Light and dark styles
  • Custom view items
  • Setting item label text color & icon color for each individual item
  • Setting custom popup background color
  • Customizing default popup style via theme attribute
  • Adding additional offsets to where the dialog should be shown
  • Keeping popup open after clicking on item
  • Dimming background behind popup
  • Customizing popup width, padding & offsets
  • Displaying an icon at the end of each item which indicates a nested submenu

Custom views

You can use your own layouts for displaying the items in each section alongside the default layouts provided by the library. E.g.:

    fun onCustomItemsClicked(view: View) {
        val popupMenu = popupMenu {
            dropdownGravity = Gravity.END
            section {
                item {
                    label = "Copy"
                    icon = R.drawable.abc_ic_menu_copy_mtrl_am_alpha
                    callback = {
                        Toast.makeText(this@LightActivity, "Copied!", Toast.LENGTH_SHORT).show()
                    }
                }
                customItem {
                    layoutResId = R.layout.view_custom_item_checkable
                    viewBoundCallback = { view ->
                        val checkBox: CheckBox = view.findViewById(R.id.customItemCheckbox)
                        checkBox.isChecked = true
                    }
                    callback = {
                        Toast.makeText(this@LightActivity, "Disabled!", Toast.LENGTH_SHORT).show()
                    }
                }
                customItem {
                    layoutResId = R.layout.view_custom_item_large
                }
            }
        }

        popupMenu.show(this@LightActivity, view)
    }

Custom colors

To achieve the above you need to set labelColor and iconColor on each item in a section as shown here:

    fun onCustomColorsClicked(view: View) {
        val popupMenu = popupMenu {
            style = R.style.Widget_MPM_Menu_Dark_CustomBackground
            section {
                item {
                    label = "Copy"
                    labelColor = ContextCompat.getColor(this@LightActivity, R.color.red)
                    icon = R.drawable.abc_ic_menu_copy_mtrl_am_alpha
                    iconColor = ContextCompat.getColor(this@LightActivity, R.color.dark_red)
                    callback = {
                        Toast.makeText(this@LightActivity, "Copied!", Toast.LENGTH_SHORT).show()
                    }
                }
                item {
                    label = "Paste"
                    labelColor = ContextCompat.getColor(this@LightActivity, R.color.red)
                    icon = R.drawable.abc_ic_menu_paste_mtrl_am_alpha
                    iconColor = ContextCompat.getColor(this@LightActivity, R.color.dark_red)
                    callback = {
                        Toast.makeText(this@LightActivity, "Text pasted!", Toast.LENGTH_SHORT).show()
                    }
                }
            }
            section {
                item {
                    label = "Share"
                    labelColor = ContextCompat.getColor(this@LightActivity, R.color.green)
                    icon = R.drawable.abc_ic_menu_share_mtrl_alpha
                    iconColor = ContextCompat.getColor(this@LightActivity, R.color.dark_green)
                    callback = {
                        shareUrl()
                    }
                }
            }
        }

        popupMenu.show(this@LightActivity, view)
    }

To change the popup background color you need to create a custom style and pass it under style to the popup builder above. E.g. to use the primary color you could define the style like this:

<resources>
    <style name="Widget.MPM.Menu.Dark.CustomBackground">
        <item name="android:colorBackground">@color/colorPrimary</item>
    </style>
</resources>

Documentation

HTML documentation of the current version of the library is available here.

Third Party Bindings

React Native

You may now use this library with React Native via the module here

FAQ

I want to use the library but I don't know Kotlin

Kotlin is extremely easy to use if you already know Java. Check out the official documentation - it's really great!

I have not migrated to AndroidX. Can I use this library?

If you're still using legacy Android Support libraries you can use version 2.2.0. AndroidX is supported by default since 3.0.0.

Can I use this library on Jelly Bean?

Up to 3.4.0 minimum supported version was API 16 (Jelly Bean) so you can use that version. Since 4.0.0 minimum supported version is API 19 (Kitkat).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].