{"id":13790224,"url":"https://github.com/skydoves/powermenu","last_synced_at":"2025-10-04T02:08:15.216Z","repository":{"id":37733956,"uuid":"108719833","full_name":"skydoves/PowerMenu","owner":"skydoves","description":":fire:  Powerful and modernized popup menu with fully customizable animations.","archived":false,"fork":false,"pushed_at":"2023-06-28T09:15:31.000Z","size":8234,"stargazers_count":1195,"open_issues_count":15,"forks_count":178,"subscribers_count":28,"default_branch":"main","last_synced_at":"2025-10-02T15:33:00.940Z","etag":null,"topics":["android","android-library","android-menu","dialog","popup","popup-menu","popup-window","powermenu","skydoves"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skydoves.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"skydoves","custom":["https://www.paypal.me/skydoves","https://www.buymeacoffee.com/skydoves"]}},"created_at":"2017-10-29T09:08:27.000Z","updated_at":"2025-09-27T07:05:00.000Z","dependencies_parsed_at":"2024-05-03T15:36:44.801Z","dependency_job_id":null,"html_url":"https://github.com/skydoves/PowerMenu","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/skydoves/PowerMenu","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skydoves%2FPowerMenu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skydoves%2FPowerMenu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skydoves%2FPowerMenu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skydoves%2FPowerMenu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skydoves","download_url":"https://codeload.github.com/skydoves/PowerMenu/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skydoves%2FPowerMenu/sbom","scorecard":{"id":830551,"data":{"date":"2025-08-11","repo":{"name":"github.com/skydoves/PowerMenu","commit":"0dab20dae71a4f452095b85e22a1c7dcb52e8081"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 1/16 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/android.yml:1","Warn: no topLevel permission defined: .github/workflows/publish-snapshot.yml:1","Warn: no topLevel permission defined: .github/workflows/publish.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Binary-Artifacts","score":9,"reason":"binaries present in source code","details":["Warn: binary detected: gradle/wrapper/gradle-wrapper.jar:1"],"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/android.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/skydoves/PowerMenu/android.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/android.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/skydoves/PowerMenu/android.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/android.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/skydoves/PowerMenu/android.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/android.yml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/skydoves/PowerMenu/android.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/android.yml:38: update your workflow using https://app.stepsecurity.io/secureworkflow/skydoves/PowerMenu/android.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish-snapshot.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/skydoves/PowerMenu/publish-snapshot.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish-snapshot.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/skydoves/PowerMenu/publish-snapshot.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/skydoves/PowerMenu/publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/skydoves/PowerMenu/publish.yml/main?enable=pin","Info:   0 out of   9 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 21 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T17:40:17.552Z","repository_id":37733956,"created_at":"2025-08-23T17:40:17.552Z","updated_at":"2025-08-23T17:40:17.552Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278254466,"owners_count":25956604,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","android-menu","dialog","popup","popup-menu","popup-window","powermenu","skydoves"],"created_at":"2024-08-03T22:00:39.115Z","updated_at":"2025-10-04T02:08:15.181Z","avatar_url":"https://github.com/skydoves.png","language":"Java","readme":"\u003ch1 align=\"center\"\u003ePowerMenu\u003c/h1\u003e\u003c/br\u003e\n\u003cp align=\"center\"\u003e\n:fire: PowerMenu is a modernized and fully customizable popup menu, which can be displayed on top of layouts. \u003cbr\u003e\n\u003c/p\u003e\n\u003c/br\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://devlibrary.withgoogle.com/products/android/repos/skydoves-powermenu\"\u003e\u003cimg alt=\"Google\" src=\"https://skydoves.github.io/badges/google-devlib.svg\"/\u003e\u003c/a\u003e\u003cbr\u003e\n  \u003ca href=\"https://opensource.org/licenses/Apache-2.0\"\u003e\u003cimg alt=\"License\" src=\"https://img.shields.io/badge/License-Apache%202.0-blue.svg\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://android-arsenal.com/api?level=15\"\u003e\u003cimg alt=\"API\" src=\"https://img.shields.io/badge/API-15%2B-brightgreen.svg?style=flat\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/skydoves/PowerMenu/actions\"\u003e\u003cimg alt=\"CI\" src=\"https://github.com/skydoves/PowerMenu/workflows/Android%20CI/badge.svg\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://androidweekly.net/issues/issue-326\"\u003e\u003cimg alt=\"AndroidWeekly\" src=\"https://skydoves.github.io/badges/android-weekly.svg\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://proandroiddev.com/building-a-beautiful-disney-android-application-1-material-motion-systems-34607eae2501\"\u003e\u003cimg alt=\"Medium\" src=\"https://skydoves.github.io/badges/Story-Medium.svg\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/skydoves\"\u003e\u003cimg alt=\"Profile\" src=\"https://skydoves.github.io/badges/skydoves.svg\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://medium.com/@skydoves/how-to-implement-modern-popup-in-android-3d51f4a40c56\"\u003e\u003cimg alt=\"Javadoc\" src=\"https://img.shields.io/badge/Javadoc-PowerMenu-yellow.svg\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003c/br\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/24237865/63956079-c0e0cb80-cac0-11e9-82ca-4397ca1f3750.gif\" width=\"32%\"/\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/24237865/63956377-42385e00-cac1-11e9-9639-81eac4b7511f.jpg\" width=\"32%\"/\u003e\n\u003c/p\u003e\n\n## Download\n[![Maven Central](https://img.shields.io/maven-central/v/com.github.skydoves/powermenu.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.github.skydoves%22%20AND%20a:%22powermenu%22)\n\nI really appreciate that 🔥 PowerMenu has been used in more than __340,000+__ projects all over the world. 🌎 \u003cbr\u003e\n\n![screenshot1903218121](https://user-images.githubusercontent.com/24237865/64470618-49c2cb80-d181-11e9-99b4-0e14a20a86a0.png)\n\n### Gradle\nAnd add the dependency below to your **module**'s `build.gradle` file:\n```gradle\ndependencies {\n  implementation \"com.github.skydoves:powermenu:2.2.4\"\n}\n```\n\n## Table of Contents\n__[1. PowerMenu](https://github.com/skydoves/PowerMenu#usage)__ \u003cbr\u003e\n__[2. Customizing Popup](https://github.com/skydoves/PowerMenu#customizing-popup)__ \u003cbr\u003e\n__[3. Preference](https://github.com/skydoves/PowerMenu#preference)__\u003cbr\u003e\n__[4. Menu Effect](https://github.com/skydoves/PowerMenu#menu-effect)__ \u003cbr\u003e\n__[5. Dialogs](https://github.com/skydoves/PowerMenu#dialogs)__ \u003cbr\u003e\n__[6. Anchor](https://github.com/skydoves/PowerMenu#anchor)__ \u003cbr\u003e\n__[7. Background](https://github.com/skydoves/PowerMenu#background)__ \u003cbr\u003e\n__[8. Avoid Memory leak](https://github.com/skydoves/PowerMenu#avoid-memory-leak)__ \u003cbr\u003e\n__[9. Functions](https://github.com/skydoves/PowerMenu#functions)__ \u003cbr\u003e\n__[10. Lazy initialization in Kotlin](https://github.com/skydoves/PowerMenu#lazy-initialization-in-kotlin)__ \u003cbr\u003e\n\n## Usage\n\n### Basic example\nThis is a basic example on a screenshot. Here is how to create `PowerMenu` using `PowerMenu.Builder`.\n```java\nPowerMenu powerMenu = new PowerMenu.Builder(context)\n          .addItemList(list) // list has \"Novel\", \"Poetry\", \"Art\"\n          .addItem(new PowerMenuItem(\"Journals\", false)) // add an item.\n          .addItem(new PowerMenuItem(\"Travel\", false)) // aad an item list.\n          .setAnimation(MenuAnimation.SHOWUP_TOP_LEFT) // Animation start point (TOP | LEFT).\n          .setMenuRadius(10f) // sets the corner radius.\n          .setMenuShadow(10f) // sets the shadow.\n          .setTextColor(ContextCompat.getColor(context, R.color.md_grey_800))\n          .setTextGravity(Gravity.CENTER)\n          .setTextTypeface(Typeface.create(\"sans-serif-medium\", Typeface.BOLD))\n          .setSelectedTextColor(Color.WHITE)\n          .setMenuColor(Color.WHITE)\n          .setSelectedMenuColor(ContextCompat.getColor(context, R.color.colorPrimary))\n          .setOnMenuItemClickListener(onMenuItemClickListener)\n          .build();\n```\n\nWe can add an item or an item list using `PowerMenuItem` class. This is how to initialize `PowerMenuItem`.\n```java\nnew PowerMenuItem(\"Travel\");\nnew PowerMenuItem(\"Poetery\", false); // item name, isSelected (default is false).\nnew PowerMenuItem(\"Art\", R.drawable.icon_art) // item name, item menu icon.\nnew PowerMenuItem(\"Travel\", R.drawable.icon_travel, true) // item name, item menu icon, isSelected .\n```\n\nThe first argument is an item **title**, and the other is **selected status**. \u003cbr\u003e\nIf **isSelected** is true, the item's text and the background color will be changed by settings like below.\u003cbr\u003e\n\n```java\n.setSelectedTextColor(Color.WHITE) // sets the color of the selected item text. \n.setSelectedMenuColor(ContextCompat.getColor(context, R.color.colorPrimary)) // sets the color of the selected menu item color.\n```\n\n`OnMenuItemClickListener` is for listening to the item click of the popup menu.\n```java\nprivate OnMenuItemClickListener\u003cPowerMenuItem\u003e onMenuItemClickListener = new OnMenuItemClickListener\u003cPowerMenuItem\u003e() {\n    @Override\n    public void onItemClick(int position, PowerMenuItem item) {\n        Toast.makeText(getBaseContext(), item.getTitle(), Toast.LENGTH_SHORT).show();\n        powerMenu.setSelectedPosition(position); // change selected item\n        powerMenu.dismiss();\n    }\n};\n```\n\nAfter implementing the listener, we should set using `setOnMenuItemClickListener` method.\n```java\n.setOnMenuItemClickListener(onMenuItemClickListener)\n```\n\nThe last, show the popup! [Various show \u0026 dismiss methods](https://github.com/skydoves/PowerMenu#show--dismiss).\n```java\npowerMenu.showAsDropDown(view); // view is an anchor\n```\n\n## Customizing Popup\nWe can customize item styles using `CustomPowerMenu` and your customized adapter. \u003cbr\u003e\nHere is how to customize the popup item that has an icon. \u003cbr\u003e\n\n![custom0](https://user-images.githubusercontent.com/24237865/45586080-5a07e800-b92b-11e8-8c7e-5aa0e524598c.png)\n![gif0](https://user-images.githubusercontent.com/24237865/45586081-5a07e800-b92b-11e8-9cba-303eb013b7c9.gif) \u003cbr\u003e\n\nFirstly, we should create our item model class.\n```java\npublic class IconPowerMenuItem {\n    private Drawable icon;\n    private String title;\n\n    public IconPowerMenuItem(Drawable icon, String title) {\n        this.icon = icon;\n        this.title = title;\n    }\n // --- skipped setter and getter methods\n}\n```\n\nAnd we should create our customized XML layout and an adapter. \u003cbr\u003e\nCustom Adapter should extend `MenuBaseAdapter\u003cYOUR_ITEM_MODEL_CLASS\u003e`.\n\n```java\npublic class IconMenuAdapter extends MenuBaseAdapter\u003cIconPowerMenuItem\u003e {\n\n    @Override\n    public View getView(int index, View view, ViewGroup viewGroup) {\n        final Context context = viewGroup.getContext();\n\n        if(view == null) {\n            LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);\n            view = inflater.inflate(R.layout.item_icon_menu, viewGroup, false);\n        }\n\n        IconPowerMenuItem item = (IconPowerMenuItem) getItem(index);\n        final ImageView icon = view.findViewById(R.id.item_icon);\n        icon.setImageDrawable(item.getIcon());\n        final TextView title = view.findViewById(R.id.item_title);\n        title.setText(item.getTitle());\n        return super.getView(index, view, viewGroup);\n    }\n}\n```\n\nThe last, create the `CustomPowerMenu` with the `onMenuItemClickListener`.\n```java\nCustomPowerMenu customPowerMenu = new CustomPowerMenu.Builder\u003c\u003e(context, new IconMenuAdapter())\n       .addItem(new IconPowerMenuItem(ContextCompat.getDrawable(context, R.drawable.ic_wechat), \"WeChat\"))\n       .addItem(new IconPowerMenuItem(ContextCompat.getDrawable(context, R.drawable.ic_facebook), \"Facebook\"))\n       .addItem(new IconPowerMenuItem(ContextCompat.getDrawable(context, R.drawable.ic_twitter), \"Twitter\"))\n       .addItem(new IconPowerMenuItem(ContextCompat.getDrawable(context, R.drawable.ic_line), \"Line\"))\n       .setOnMenuItemClickListener(onIconMenuItemClickListener)\n       .setAnimation(MenuAnimation.SHOWUP_TOP_RIGHT)\n       .setMenuRadius(10f)\n       .setMenuShadow(10f)\n       .build();\n```\n```java\nprivate OnMenuItemClickListener\u003cIconPowerMenuItem\u003e onIconMenuItemClickListener = new OnMenuItemClickListener\u003cIconPowerMenuItem\u003e() {\n    @Override\n    public void onItemClick(int position, IconPowerMenuItem item) {\n        Toast.makeText(getBaseContext(), item.getTitle(), Toast.LENGTH_SHORT).show();\n        iconMenu.dismiss();\n    }\n};\n```\n\n## Preference\nPowerMenu supports saving of the last selected menu and recovering as lifecycle.\u003cbr\u003e\nHere is how to save and recover selected menu.\n```java\nreturn new PowerMenu.Builder(context)\n    // saves the position automatically when the menu is selected.\n    // If we set the same preference name on the other PowerMenus, they will share the saving position.\n   .setPreferenceName(\"HamburgerPowerMenu\")\n\n    // invokes the listener automatically that has the saved position arguments along the lifecycle rule.\n    // lifecycle rules should be ON_CREATE, ON_START or ON_RESUME.\n    // in the below codes, the onMenuClickListener will be invoked when onCreate lifecycle.\n   .setLifecycleOwner(lifecycleOwner)\n   .setInitializeRule(Lifecycle.Event.ON_CREATE, 0) // Lifecycle.Event and default position.\n   --- skips ---\n```\nHere are the methods related to preference.\n```java\n.getPreferenceName() // gets the preference name of PowerMenu.\n.getPreferencePosition(int defaultPosition) // gets the saved preference position from the SharedPreferences.\n.setPreferencePosition(int defaultPosition) // sets the preference position name for persistence manually.\n.clearPreference() // clears the preference name of PowerMenu.\n```\n\n## Menu Effect\nWe can give two types of circular revealed animation effect.\u003cbr\u003e\u003cbr\u003e\n![menu_effect01](https://user-images.githubusercontent.com/24237865/52637461-9a878400-2f12-11e9-8a78-decfc1641d5b.gif)\n![menu_effect02](https://user-images.githubusercontent.com/24237865/52637462-9a878400-2f12-11e9-935d-189c518fe435.gif)\n\u003cbr\u003e\nHere is how to create a menu effect simply.\n```java\n.setCircularEffect(CircularEffect.BODY) // shows circular revealed effects for all body of the popup menu.\n.setCircularEffect(CircularEffect.INNER) // Shows circular revealed effects for the content view of the popup menu.\n```\n\n## Dialogs\nWe can create looks like dialogs using `PowerMenu`.\u003cbr\u003e\u003cbr\u003e\n![screenshot_2017-12-18-23-39-00](https://user-images.githubusercontent.com/24237865/34111113-1de9bfce-e44c-11e7-9b60-44b8d440b910.png)\n![screenshot_2017-12-18-23-39-05](https://user-images.githubusercontent.com/24237865/34111114-1e19ddf8-e44c-11e7-9747-17713d2932bd.png)\n\u003cbr\u003e\n\nHere is an example of the normal dialog. Dialogs are composed of a header, footer, and body. \u003cbr\u003e\n```java\nPowerMenu powerMenu = new PowerMenu.Builder(context)\n           .setHeaderView(R.layout.layout_dialog_header) // header used for title\n           .setFooterView(R.layout.layout_dialog_footer) // footer used for yes and no buttons\n           .addItem(new PowerMenuItem(\"This is DialogPowerMenu\", false)) // this is body\n           .setLifecycleOwner(lifecycleOwner)\n           .setAnimation(MenuAnimation.SHOW_UP_CENTER)\n           .setMenuRadius(10f)\n           .setMenuShadow(10f)\n           .setWith(600)\n           .setSelectedEffect(false)\n           .build();\n```\n\nAnd we can create a customized dialog like below.\n```java\nCustomPowerMenu customPowerMenu = new CustomPowerMenu.Builder\u003c\u003e(context, new CustomDialogMenuAdapter())\n         setHeaderView(R.layout.layout_custom_dialog_header) // header used for title\n        .setFooterView(R.layout.layout_custom_dialog_footer) // footer used for Read More and Close buttons\n         // this is body\n        .addItem(new NameCardMenuItem(ContextCompat.getDrawable(context, R.drawable.face3), \"Sophie\", context.getString(R.string.board3)))\n        .setLifecycleOwner(lifecycleOwner)\n        .setAnimation(MenuAnimation.SHOW_UP_CENTER)\n        .setWith(800)\n        .setMenuRadius(10f)\n        .setMenuShadow(10f)\n        .build();\n```\n\n## Anchor\nWe can show the popup menu as drop down to the anchor. \u003cbr\u003e\u003cbr\u003e\n\n\u003cimg src=\"https://user-images.githubusercontent.com/24237865/38161125-da1ac0aa-3503-11e8-9a91-7dc4f8f4d9c3.gif\" align=\"left\" width=\"30%\"\u003e\n\n```java\n.showAsAnchorLeftTop(view) // showing the popup menu as left-top aligns to the anchor.\n.showAsAnchorLeftBottom(view) // showing the popup menu as left-bottom aligns to the anchor.\n.showAsAnchorRightTop(view) // using with .setAnimation(MenuAnimation.SHOWUP_TOP_RIGHT) looks better\n.showAsAnchorRightBottom(view) // using with .setAnimation(MenuAnimation.SHOWUP_TOP_RIGHT) looks better\n.showAsAnchorCenter(view) // using with .setAnimation(MenuAnimation.SHOW_UP_CENTER) looks better\n```\n\nor we can control the position of the popup menu using the below methods.\n```java\n.getContentViewWidth() // return popup's measured width\n.getContentViewHeight() // return popup's measured height\n```\n\nlike this :\n```java\n// showing the popup menu at the center of an anchor. This is the same using .showAsAnchorCenter.\nhamburgerMenu.showAsDropDown(view, \n        view.getMeasuredWidth()/2 - hamburgerMenu.getContentViewWidth(), \n       -view.getMeasuredHeight()/2 - hamburgerMenu.getContentViewHeight());\n```\n\u003cbr\u003e\n\n## Background\nThese are options for the background.\n```java\n.setShowBackground(false) // do not showing background.\n.setTouchInterceptor(onTouchListener) // sets the touch listener for the outside of popup.\n.setFocusable(true) // makes focusing only on the menu popup.\n```\n\n## Avoid Memory leak\nDialog, PopupWindow and etc.. have memory leak issue if not dismissed before activity or fragment are destroyed.\u003cbr\u003e\nBut Lifecycles are now integrated with the Support Library since Architecture Components 1.0 Stable released.\u003cbr\u003e\nSo we can solve the memory leak issue so easily.\u003cbr\u003e\n\nJust use `setLifecycleOwner` method. Then `dismiss` method will be called automatically before activity or fragment would be destroyed.\n```java\n.setLifecycleOwner(lifecycleOwner)\n```\n\n## Lazy initialization in Kotlin\nWe can initialize the `PowerMenu` property lazily using `powerMenu` keyword and `PowerMenu.Factory` abstract class.\u003cbr\u003e\nThe `powerMenu` extension keyword can be used in Activity and Fragment.\n\n```kotlin\nclass MainActivity : AppCompatActivity() {\n\n  private val moreMenu by powerMenu(MoreMenuFactory::class)\n  \n  //..\n```\nWe should create a factory class which extends `PowerMenu.Factory`.\u003cbr\u003e\nAn implementation class of the factory must have a default(non-argument) constructor.\n\n```kotlin\nclass MoreMenuFactory : PowerMenu.Factory() {\n\n  override fun create(context: Context, lifecycle: LifecycleOwner?): PowerMenu {\n    return createPowerMenu(context) {\n      addItem(PowerMenuItem(\"Novel\", true))\n      addItem(PowerMenuItem(\"Poetry\", false))\n      setAutoDismiss(true)\n      setLifecycleOwner(lifecycle)\n      setAnimation(MenuAnimation.SHOWUP_TOP_LEFT)\n      setTextColor(ContextCompat.getColor(context, R.color.md_grey_800))\n      setTextSize(12)\n      setTextGravity(Gravity.CENTER)\n      setTextTypeface(Typeface.create(\"sans-serif-medium\", Typeface.BOLD))\n      setSelectedTextColor(Color.WHITE)\n      setMenuColor(Color.WHITE)\n      setInitializeRule(Lifecycle.Event.ON_CREATE, 0)\n    }\n  }\n}\n```\n\n## Functions\n### PowerMenu methods\n```java\n.addItemList(list) // add a PowerMenuItem list.\n.addItem(new PowerMenuItem(\"Journals\", false)) // add a PowerMenuItem.\n.addItem(3, new PowerMenuItem(\"Travel\", false)) // add a PowerMenuItem at position 3.\n.setLifecycleOwner(lifecycleOwner) // set LifecycleOwner for preventing memory leak.\n.setWith(300) // sets the popup width size.\n.setHeight(400) // sets the popup height size.\n.setMenuRadius(10f) // sets the popup corner radius.\n.setMenuShadow(10f) // sets the popup shadow.\n.setDivider(new ColorDrawable(ContextCompat.getColor(context, R.color.md_blue_grey_300))) // sets a divider.\n.setDividerHeight(1) // sets the divider height.\n.setAnimation(MenuAnimation.FADE) // sets animations of the popup. It will start up when the popup is showing.\n.setTextColor(ContextCompat.getColor(context, R.color.md_grey_800)) // sets the color of the default item text.\n.setTextSize(12) // sets a text size of the item text\n.setTextGravity(Gravity.CENTER) // sets a gravity of the item text.\n.setTextTypeface(Typeface.create(\"sans-serif-medium\", Typeface.BOLD)) // sets a typeface of the item text\n.setSelectedTextColor(Color.WHITE) // sets the color of the selected item text.\n.setMenuColor(Color.WHITE) // sets the color of the menu item color.\n.setSelectedMenuColor(ContextCompat.getColor(context, R.color.colorPrimary)) // sets the color of the selected menu item color.\n.setSelectedEffect(false) // sets the selected effects what changing colors of the selected menu item.\n.setOnMenuItemClickListener(onMenuItemClickListener) // sets an item click listener.\n.setOnDismissListener(OnDismissedListener onDismissListener) // sets a menu dismiss listener.\n.setHeaderView(View view) //  sets the header view of the popup menu list.\n.setHeaderView(int layout) // sets the header view of the popup menu using layout.\n.setFooterView(View view) // sets the footer view of the popup menu list.\n.setFooterView(int layout) // sets the footer view of the popup menu using layout.\n.setSelection(int position) // sets the selected position of the popup menu. It can be used for scrolling as the position.\n.getSelectedPosition() // gets the selected item position. if not selected before, returns -1 .\n.getHeaderView() // gets the header view of the popup menu list.\n.getFooterView() // gets the footer view of the popup menu list.\n.getMenuListView() // gets the ListView of the popup menu.\n```\n\n### Background methods\n```java\n.setBackgroundAlpha(0.7f) // sets the alpha of the background.\n.setBackgroundColor(Color.GRAY) // sets the color of the background.\n.setShowBackground(false) // sets the background is showing or not.\n.setOnBackgroundClickListener(onClickListener) // sets the background click listener of the background.\n```\n\n### Show \u0026 Dismiss\n```java\n.showAsDropDown(View anchor); // showing the popup menu as drop down to the anchor.\n.showAsDropDown(View anchor, -370, 0); // showing the popup menu as drop down to the anchor with x-off and y-off.\n.showAtCenter(View layout); // showing the popup menu as center aligns to the anchor.\n.showAtCenter(View layout, 0, 0); // showing the popup menu as center aligns to the anchor with x-off and y-off.\n.showAtLocation(View anchor, int xOff, int yOff) // showing the popup menu as center aligns to the anchor with x-off and y-off.\n.showAtLocation(View anchor, int gravity, int xOff, int yOff) // showing the popup menu to the specific location to the anchor with Gravity.\n.isShowing(); // gets the popup is showing or not.\n.dismiss(); // dismiss the popup.\n```\n\n## Find this library useful? :heart:\nSupport it by joining [stargazers](https://github.com/skydoves/PowerMenu/stargazers) for this repository. :star: \u003cbr\u003e\nAnd __[follow](https://github.com/skydoves)__ me for my next creations! 🤩\n\n# License\n```xml\nCopyright 2017 skydoves\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","funding_links":["https://github.com/sponsors/skydoves","https://www.paypal.me/skydoves","https://www.buymeacoffee.com/skydoves"],"categories":["Index"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskydoves%2Fpowermenu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskydoves%2Fpowermenu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskydoves%2Fpowermenu/lists"}