Monday, August 31, 2020

How to create Circle Menu Android Example

Circle Menu Android is a simple, elegant UI menu with a circular layout and material design animations. Android UI library.

How to create Circle Menu Android Example


Setup

Add this to your app build.gradle:

implementation 'com.github.imangazalievm:circlemenu:3.0.0'

Usage

Add to your layout xml-file:

<com.imangazaliev.circlemenu.CircleMenu

        android:id="@+id/circleMenu"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        app:buttonColors="@array/colors"

        app:buttonIcons="@array/icons" />

Handling menu items clicks:

val circleMenu = findViewById<CircleMenu>(R.id.circleMenu);

circleMenu.setOnItemClickListener { menuButton ->   }

You can use open(boolean animate) and close(boolean animate) methods, to open and close menu programmatically

circleMenu.open(true)

Set EventListener for handling open/close actions

circleMenu.setOnItemClickListener { buttonIndex -> }

circleMenu.onMenuOpenAnimationStart { }

circleMenu.onMenuOpenAnimationEnd { }

circleMenu.onMenuCloseAnimationStart { }

circleMenu.onMenuCloseAnimationEnd { }

circleMenu.onButtonClickAnimationStart { buttonIndex -> }

circleMenu.onButtonClickAnimationEnd { buttonIndex -> }

Options

CircleMenu XML-options:

  • buttonIcons (required) - icons of menu buttons
  • buttonColors (required) - background colors of menu buttons
  • iconsColor - color of buttons icons
  • startAngle - start circle angle
  • maxAngle - maximum degree of the menu arc
  • distance - the distance between center menu and buttons (radius)
  • centerButtonColor - background color of center menu button
  • centerButtonIconColor - icon background color of center menu button
  • menuIcon - center button icon type: hamburger or plus
  • openOnStart - open the menu when the screen starts
  • showSelectAnimation - show select animation when clicking on on a button or just close the menu

No comments:

Post a Comment