If you check the source code of DrawerLayout, you will see that resposnible for this minimum field is the variable mMinDrawerMargin
So, there are at least 2 solutions (tricks) 1. continue DrawerLayout and set this variable to 0 with reflection. call this method from all the constructors.
private void init() { try { Field declaredField = getClass().getSuperclass().getDeclaredField("mMinDrawerMargin"); declaredField.setAccessible(true); declaredField.setInt(declaredField, 0); } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } }
- not so hard
overryde onMeasure method like this
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // taken from parents logic float density = this.getResources().getDisplayMetrics().density; int minMargin = (int) (64.0F * density + 0.5F); int widthMode = MeasureSpec.getMode(widthMeasureSpec); int widthSize = MeasureSpec.getSize(widthMeasureSpec); int newWidth = MeasureSpec.makeMeasureSpec(widthSize + minMargin, widthMode); super.onMeasure(newWidth, heightMeasureSpec); }
I also created a sample project here https://bitbucket.org/wnc_21/fsnavigationdrawer
source share