Search code examples
androidslidingmenuandroid-sliding

How to create custom sliding Menu bar without using actionbar in android?


I would like design sliding menu bar on my layout button click or slide the screen : enter image description here

on menu button click :

enter image description here


Solution

  • You can download SlidingMenu from GitHub which is an OpenSource Android library.

    If you don't want to use the menu bar from the library, you can create a custom view and include it to your Activity. And to open the SlidingMenu, you can set onClickListenner to your Button in the custom Menu bar.

    Based from another answer, you have to extend SherlockActivity, and create a menu.xml which will be your custom menu layout.

    Then just add those few lines in your onCreate method.

    menu = new SlidingMenu(this);
    menu.setMode(SlidingMenu.LEFT);
    menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    menu.setShadowWidthRes(R.dimen.shadow_width);
    menu.setShadowDrawable(R.drawable.shadow);
    menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    menu.setFadeDegree(0.35f);
    menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
    menu.setMenu(R.layout.menu);