我试图弄清楚如何通过https://github.com/mikepenz/MaterialDrawer自定义 MaterialDrawer
目前宽度太大。我想用更大的图标缩小宽度以覆盖空间并更改背景颜色。
此应用程序仅适用于平板电脑。谢谢。
这是我的抽屉:
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Place your content here -->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button2"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="215dp" />
</RelativeLayout>
</LinearLayout>
result = new DrawerBuilder()
.withActivity(this)
.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),
new PrimaryDrawerItem().withName("3").withIcon(FontAwesome.Icon.faw_home).withIdentifier(3)
) // 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);
LinearLayout container = (LinearLayout) findViewById(R.id.container);
container.addView(view, 0); //view is the view of your MiniDrawer
谢谢
我最初在这里问了一个关于如何启用固定迷你抽屉的问题 Android build mini navigation drawer with Icons