Search code examples
androidmaterialdrawer

Overwrite MaterialDrawer's RecyclerView


According to this commit, it is possible to rewrite drawer's RecyclerView with a custom one but I can't figure out how to do it.

Can anyone explain to me how to do it properly?


Solution

  • You can provide any RecyclerView you want with withRecyclerView(). This will then be picked instead of the default implementation. Just provide a RecyclerView object (which you have retrieved via a LayoutInflater or created programmatically) set the LayoutManager the Animator and everything else you need.

    If you are interested what happens in the default behavior follow this link: https://github.com/mikepenz/MaterialDrawer/blob/develop/library/src/main/java/com/mikepenz/materialdrawer/DrawerBuilder.java#L1576

    As of your issue. It is also possible to just retrieve the default generated RecyclerView after the Drawer was built, via getRecyclerView(), which will also allow you to adjust some things like paddings, and other things. See here: https://github.com/mikepenz/MaterialDrawer/blob/develop/library/src/main/java/com/mikepenz/materialdrawer/Drawer.java#L214

    As also discussed here: https://github.com/mikepenz/MaterialDrawer/issues/1290