I'm trying to develop an application using Jeremy Feinstein's SlidingMenu library. All I have done in the right way as described in the Github instructions. Everything is working well, but the problem is that when I click on action bar home button to open the slider it covers the complete screen. I want it to open in half open like in Facebook slider in Facebook app. My code is below:
public class MainActivity extends SlidingFragmentActivity {
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Hide title bar
getSupportActionBar().setDisplayShowTitleEnabled(true);
//Enable home button
getSupportActionBar().setHomeButtonEnabled(true);
//Home as up display
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
setBehindContentView(R.layout.menu_frame);
//SlidingMenu menu=getSlidingMenu();
SlidingMenu menu=new SlidingMenu(this);
//menu = new SlidingMenu(MainActivity.this);
menu.setMode(SlidingMenu.LEFT);
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
setSlidingActionBarEnabled(true);
menu.setShadowWidth(5);
menu.setFadeDegree(0.0f);
menu.attachToActivity(MainActivity.this, SlidingMenu.SLIDING_CONTENT);
menu.setBehindWidth(10);
menu.setBehindOffset(10);
menu.setBehindScrollScale(0.25f);
menu.setMenu(R.layout.menu_frame);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
toggle();
return true;
}
return super.onOptionsItemSelected(item);
}
}
You could use behindOffset
, behindWidth
or touchModeAbove
.
If you use it as a view you could do this (in your layout file):
sliding:behindOffset="@dimen/YOUR_OFFSET"
sliding:behindWidth="@dimen/YOUR_WIDTH"
sliding:touchModeAbove="margin"
Further explained
touchModeAbove
- an enum that designates what part of the screen is touchable when the above view is showing. Margin means only the left margin. Fullscreen means the entire screen. Default is margin.
behindOffset
- a dimension representing the number of pixels that you want the above view to show when the behind view is showing. Default is 0.
behindWidth
- a dimension representing the width of the behind view. Default is the width of the screen (equivalent to behindOffset = 0).