【开源】MaterialNavigationDrawer
MaterialNavigationDrawer
- https://github.com/neokree/MaterialNavigationDrawer
介绍:
Material风格的侧滑菜单控件,需要14+ API 和 android support v7 (Toolbar)运行效果:

使用说明:
activity中:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
public class MyActivity extends MaterialNavigationDrawer { @Override public Fragment getCurrentFragment(int position) { switch(position) { case MaterialNavigationDrawer.SECTION_START: return new Fragment1(); case MaterialNavigationDrawer.SECTION_START + 1: return new Fragment2(); case MaterialNavigationDrawer.BOTTOM_SECTION_START: return new FragmentSettings(); default: return new Fragment(); } } @Override public void init(Bundle savedInstanceState) { // set cover background this.setDrawerBackground(this.getResources().getDrawable(R.drawable.mat1)); // set user photo and data this.setUserPhoto(this.getResources().getDrawable(R.drawable.photo)); this.setUsername("NeoKree"); this.setUserEmail("neokree@gmail.com"); // add your sections this.addSection(this.newSection("Section 1")); this.addSection(this.newSection("Section 2",this.getResources().getDrawable(R.drawable.ic_mic_white_24dp))); this.addBottomSection(this.newBottomSection("Settings",this.getResources().getDrawable(R.drawable.ic_settings_black_24dp))); } @Override public String getCurrentTitle(int position) { switch(position) { case MaterialNavigationDrawer.SECTION_START: return "My First Section"; case MaterialNavigationDrawer.SECTION_START + 1: return "My Second Section"; case MaterialNavigationDrawer.BOTTOM_SECTION_START: return "Settings"; default: return ""; } }} |
style文件中:
|
1
2
3
4
5
6
7
8
9
10
|
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/light_blue_500</item> <item name="colorPrimaryDark">@color/light_blue_800</item> <item name="colorAccent">@color/grey_1000</item> <item name="windowActionBar">false</item> </style></resources> |
注意重写的是init方法不是onCreate方法。
posted on 2015-03-27 10:35 wasdchenhao 阅读(116) 评论(0) 收藏 举报
浙公网安备 33010602011771号