我想在 android 中构建一个固定的迷你导航抽屉。将始终可见且不可扩展,仅带有图标。
像https://github.com/mikepenz/MaterialDrawer迷你抽屉。我尝试使用他的图书馆,但我不知道如何修复它。
这是我的代码:
private Drawer result = null;
private MiniDrawer miniResult = null;
result = new DrawerBuilder()
.withActivity(this)
.withToolbar(toolbar)
.withTranslucentStatusBar(false)
.addDrawerItems(
new PrimaryDrawerItem().withName("1").withIcon(FontAwesome.Icon.faw_home).withIdentifier(1),
new PrimaryDrawerItem().withName("2").withIcon(FontAwesome.Icon.faw_home).withBadge("22").withBadgeStyle(new BadgeStyle(Color.RED, Color.RED)).withIdentifier(2).withSelectable(false),
new DividerDrawerItem(),
new ToggleDrawerItem().withName("3").withIcon(FontAwesome.Icon.faw_home).withChecked(true).withOnCheckedChangeListener(onCheckedChangeListener)
) // add the items we want to use with our Drawer
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
if (drawerItem instanceof Nameable) {
Toast.makeText(MainActivity.this, ((Nameable) drawerItem).getName().getText(MainActivity.this), Toast.LENGTH_SHORT).show();
}
return false;
}
})
.withGenerateMiniDrawer(true)
.withSavedInstance(savedInstanceState)
// build only the view of the Drawer (don't inflate it automatically in our layout which is done with .build())
.buildView();
miniResult = result.getMiniDrawer();
View view = miniResult.build(this);