Full width Navigation Drawer

后端 未结 14 782
名媛妹妹
名媛妹妹 2020-12-08 03:57

I\'d like to create a full width navigation drawer. Setting layout_width to match_parent on @+id/left_drawer yields in width of about

14条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-08 04:39

    A variant on Grogory's solution:

    Instead of subclassing I call the following utility method right after I grab a reference to the drawer layout:

    /**
     * The specs tell that
     * 
      *
    1. Navigation Drawer should be at most 5*56dp wide on phones and 5*64dp wide on tablets.
    2. *
    3. Navigation Drawer should have right margin of 56dp on phones and 64dp on tablets.
    4. *
    * yet the minimum margin is hardcoded to be 64dp instead of 56dp. This fixes it. */ public static void fixMinDrawerMargin(DrawerLayout drawerLayout) { try { Field f = DrawerLayout.class.getDeclaredField("mMinDrawerMargin"); f.setAccessible(true); f.set(drawerLayout, 0); drawerLayout.requestLayout(); } catch (Exception e) { e.printStackTrace(); } }

提交回复
热议问题