MaterialDrawerAndroid 側(cè)滑顯示控件
MaterialDrawer 是一個類似 Google 官方 NavigationView 側(cè)滑顯示控件, 個人認(rèn)為 NavigationView 并沒有 MaterialDrawer 實(shí)用, 因為 NavigationView 自由度不是很好, 很多都寫死了不可以自由定義布局, 而 MaterialDrawer 能夠?qū)崿F(xiàn)跟 NavigationView 一樣的效果, 同時還支持自定義效果, 自由度非常高。
效果圖:
使用示例
//if you want to update the items at a later time it is recommended to keep it in a variablePrimaryDrawerItem item1 = new PrimaryDrawerItem().withName(R.string.drawer_item_home);SecondaryDrawerItem item2 = new SecondaryDrawerItem().withName(R.string.drawer_item_settings);//create the drawer and remember the `Drawer` result objectDrawer result = new DrawerBuilder()
.withActivity(this)
.withToolbar(toolbar)
.addDrawerItems(
item1, new DividerDrawerItem(),
item2, new SecondaryDrawerItem().withName(R.string.drawer_item_settings)
)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { // do something with the clicked item :D
}
})
.build();評論
圖片
表情
