Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Action Bar cut with SlidingMenu and Overlay of ActionBar Sherlock

I'm working with the ActionBarSherlock library and the Sliding Menu library for a Black Ops 2 guide application and've tryed to insert the beatiful "Overlay" function in the same activity of the Sliding Menu. The result is:

  • The overlay doesn't work
  • Action bar cut

This is the code:

    requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.c_m_pyrrhicvictory);   
    Resources res = getResources();
    SlidingMenu 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.main_slidingmenu);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setBackgroundDrawable(getResources().
         getDrawable(R.drawable.ab_bg_black));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setSubtitle("1/10 Standard");
    getSupportActionBar().setTitle("Missions");

Screenshots: Main Activity SlidingMenu

like image 726
Rampo Avatar asked Nov 13 '22 13:11

Rampo


1 Answers

I found solution. In file SlidingMenu.java find the function

public void attachToActivity(Activity activity, int slideStyle) {
        attachToActivity(activity, slideStyle, false);
    }

and change third parameter to true, attachToActivity(activity, slideStyle, true); i.e actionbarOverlay param should be set to true. It works for me. Don't forget to add topMargin or padding into the Menu layout, because the first list item may be hidden by ActionBar. See onLayout function in CustomViewBehind.java.

like image 136
Alexey Bleikher Avatar answered Nov 15 '22 06:11

Alexey Bleikher