
點(diǎn)擊導(dǎo)航欄按鈕

滑動菜單
1.添加依賴
compile 'com.android.support:design:25.3.1' //使用NavigationView
compile 'de.hdodenhof:circleimageview:2.1.0'//使用CircleImageView實(shí)現(xiàn)圖片圓形化
2.準(zhǔn)備在NavigationView中顯示的菜單項(xiàng),創(chuàng)建Menu resource file (nav_menu.xml文件)
? ? ? ? 其中:checkableBehavior表示只能單選

nav_menu.xml
3.準(zhǔn)備在NavigationView中顯示的頭部布局,在layout文件下創(chuàng)建 (nav_header.xml文件)
? ? ? ? 使用CircleImageView將頭像圖片圓形化

nav_header.xml
4.在activity_main.xml中
? ? 首先,使用的是DrawerLayout來實(shí)現(xiàn)側(cè)滑,在DrawerLayout中可以放置兩個(gè)布局,分別表示主布局和側(cè)布局
? ? 之后,使用NavigationView將header和menu放進(jìn)去

activity_main.xml
5.在MainActivity.java中
? ? 首先設(shè)置ToolBar 設(shè)置導(dǎo)航按鈕

MainActivity.java