public Drawer buildView ( ) { // get the slider view mSliderLayout = ( ScrimInsetsRelativeLayout ) mActivity . getLayoutInflater ( ) . inflate ( R . layout . material_drawer_slider , mDrawerLayout , false ) ; mSliderLayout . setBackgroundColor ( UIUtils . getThemeColorFromAttrOrRes ( mActivity , R . attr . material_drawer_background , R . color . material_drawer_background ) ) ; // get the layout params DrawerLayout . LayoutParams params = ( DrawerLayout . LayoutParams ) mSliderLayout . getLayoutParams ( ) ; if ( params != null ) { // if we've set a custom gravity set it params . gravity = mDrawerGravity ; // if this is a drawer from the right, change the margins :D params = DrawerUtils . processDrawerLayoutParams ( this , params ) ; // set the new layout params mSliderLayout . setLayoutParams ( params ) ; } //create the content createContent ( ) ; //create the result object Drawer result = new Drawer ( this ) ; //set the drawer for the accountHeader if set if ( mAccountHeader != null ) { mAccountHeader . setDrawer ( result ) ; } //toggle selection list if we were previously on the account list if ( mSavedInstance != null && mSavedInstance . getBoolean ( Drawer . BUNDLE_DRAWER_CONTENT_SWITCHED , false ) ) { mAccountHeader . toggleSelectionList ( mActivity ) ; } //handle if the drawer should be shown on launch handleShowOnLaunch ( ) ; //we only want to hook a Drawer to the MiniDrawer if it is the main drawer, not the appended one if ( ! mAppended && mGenerateMiniDrawer ) { // if we should create a MiniDrawer we have to do this now mMiniDrawer = new MiniDrawer ( ) . withDrawer ( result ) . withAccountHeader ( mAccountHeader ) ; } //forget the reference to the activity mActivity = null ; return result ; }
build the drawers content only . This will still return a Result object but only with the content set . No inflating of a DrawerLayout .