As others have said, and Cheney has said in his answer - it's probably best to leave it as intended. However, the DrawerLayout
is a different style than the SlidingMenu
. Google also added SlidingPaneLayout
which matches the style of SlidingMenu more closely.
I ended up implementing a SlidingPaneLayout
in this way, as it was more of what I was looking for after all. (This is also the style of the YouTube/Hangouts app)
<android.support.v4.widget.SlidingPaneLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sliding_pane_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/left_pane"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
</android.support.v4.widget.SlidingPaneLayout>
Then to open with the action bar home button:
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action buttons
switch(item.getItemId()) {
case android.R.id.home:
if (mPaneLayout.isOpen())
mPaneLayout.closePane();
else
mPaneLayout.openPane();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
You can then implement a PanelSlideListener
to handle when it sliding/open/closed.
I suggest reading Adam Powell's series on the navigation drawer too - part 3 gets into usage of SlidingPaneLayout vs Navigation Drawer:
Part 1 - https://plus.google.com/+AdamWPowell/posts/2zi4DXd3jkm
Part 2 - https://plus.google.com/+AdamWPowell/posts/VdgexsZeXHW
Part 3 - https://plus.google.com/+AdamWPowell/posts/8j2GVw72i1E
Part 4 - https://plus.google.com/+AdamWPowell/posts/TtBFUXhe5HU