You are on page 1of 2

Step 1.

Add the JitPack repository to your build file

allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}

Step 2. Add the dependency

dependencies {
compile 'com.github.Hitomis:CircleMenu:v1.0.0'
}

Step 3. Layout

<com.hitomi.cmlibrary.CircleMenu
android:id="@+id/circle_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
/>

Code

Step 4. Create Menu and Sub Menu

circleMenu = (CircleMenu) findViewById(R.id.circle_menu);

circleMenu.setMainMenu(Color.parseColor("#CDCDCD"), R.mipmap.icon_menu,
R.mipmap.icon_cancel);
circleMenu.addSubMenu(Color.parseColor("#258CFF"), R.mipmap.icon_home)
.addSubMenu(Color.parseColor("#30A400"), R.mipmap.icon_search)
.addSubMenu(Color.parseColor("#FF4B32"), R.mipmap.icon_notify)
.addSubMenu(Color.parseColor("#8A39FF"), R.mipmap.icon_setting)
.addSubMenu(Color.parseColor("#FF6A00"), R.mipmap.icon_gps);

Step 5. Add Selected Listner

circleMenu.setOnMenuSelectedListener(new OnMenuSelectedListener() {

@Override
public void onMenuSelected(int index) {
switch (index) {
case 0:
Toast.makeText(MainActivity.this, "Home Button Clicked",
Toast.LENGTH_SHORT).show();
break;
case 1:
Toast.makeText(MainActivity.this, "Search button Clicked",
Toast.LENGTH_SHORT).show();
break;
case 2:
Toast.makeText(MainActivity.this, "Notify button Clciked",
Toast.LENGTH_SHORT).show();
break;
case 3:
Toast.makeText(MainActivity.this, "Settings button Clcked",
Toast.LENGTH_SHORT).show();
break;
case 4:
Toast.makeText(MainActivity.this, "GPS button Clicked",
Toast.LENGTH_SHORT).show();
break;
}
}
}

);

Step 5. Add Menu Status Change Listner


circleMenu.setOnMenuStatusChangeListener(new OnMenuStatusChangeListener() {

@Override
public void onMenuOpened() {
Toast.makeText(MainActivity.this, "Menu Opend",
Toast.LENGTH_SHORT).show();
}

@Override
public void onMenuClosed() {
Toast.makeText(MainActivity.this, "Menu Closed",
Toast.LENGTH_SHORT).show();
}
}
);

Step 6 : Handle Back Press

@Override
public void onBackPressed() {
if (circleMenu.isOpened())
circleMenu.closeMenu();
else
finish();
}