Last active
August 29, 2015 14:14
-
-
Save frogermcs/44f57794ed7e86bf51c3 to your computer and use it in GitHub Desktop.
InstaMaterial source files (Navigation drawer)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void setupDrawer() { | |
GlobalMenuView menuView = new GlobalMenuView(this); | |
menuView.setOnHeaderClickListener(this); | |
drawerLayout = DrawerLayoutInstaller.from(this) | |
.drawerRoot(R.layout.drawer_root) | |
.drawerLeftView(menuView) | |
.drawerLeftWidth(Utils.dpToPx(300)) | |
.withNavigationIconToggler(getToolbar()) | |
.build(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:id="@+id/drawerLayout" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<FrameLayout | |
android:id="@+id/vContentFrame" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" /> | |
<FrameLayout | |
android:id="@+id/vLeftDrawer" | |
android:layout_width="280dp" | |
android:layout_height="match_parent" | |
android:layout_gravity="start" /> | |
</android.support.v4.widget.DrawerLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void addDrawerToActivity(DrawerLayout drawerLayout) { | |
ViewGroup rootView = (ViewGroup) activity.findViewById(android.R.id.content); | |
ViewGroup drawerContentRoot = (ViewGroup) drawerLayout.getChildAt(0); | |
View contentView = rootView.getChildAt(0); | |
rootView.removeView(contentView); | |
drawerContentRoot.addView(contentView, new ViewGroup.LayoutParams( | |
ViewGroup.LayoutParams.MATCH_PARENT, | |
ViewGroup.LayoutParams.MATCH_PARENT | |
)); | |
rootView.addView(drawerLayout, new ViewGroup.LayoutParams( | |
ViewGroup.LayoutParams.MATCH_PARENT, | |
ViewGroup.LayoutParams.MATCH_PARENT | |
)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment