The easiest solution is to expand one of the existing DrawerItems , but this only works if you do not need a completely different element.
CustomDrawerItem is already shown in the sample application.
public class CustomPrimaryDrawerItem extends PrimaryDrawerItem { private ColorHolder background; public CustomPrimaryDrawerItem withBackgroundColor(int backgroundColor) { this.background = ColorHolder.fromColor(backgroundColor); return this; } public CustomPrimaryDrawerItem withBackgroundRes(int backgroundRes) { this.background = ColorHolder.fromColorRes(backgroundRes); return this; } @Override public void bindView(RecyclerView.ViewHolder holder) { super.bindView(holder); if (background != null) { background.applyToBackground(holder.itemView); } } }
If you need more customization, just IDrawerItem interface and implement the methods. A simpler DrawerItem that implements AbstractDrawerItem that comes with several predefined methods and properties is DividerDrawerItem
public class DividerDrawerItem extends AbstractDrawerItem<DividerDrawerItem> { @Override public String getType() { return "DIVIDER_ITEM"; } @Override @LayoutRes public int getLayoutRes() { return R.layout.material_drawer_item_divider; } @Override public void bindView(RecyclerView.ViewHolder holder) { Context ctx = holder.itemView.getContext();
source share