【开源】GoogleNavigationDrawer

GoogleNavigationDrawer

  •  https://github.com/neokree/GoogleNavigationDrawer

    介绍:

    GoogleNavigationDrawer提供了实现抽屉效果的非常简便的方法,只需让你的activity继承自GoogleNavigationDrawer并做一些初始化就可以了。需要api14 和 support v7 (Toolbar)

    运行效果:

 

使用说明:

让你的activity继承自GoogleNavigationDrawer

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
public class MyActivity extends GoogleNavigationDrawer implements GAccountListener {
 
    @Override
    public void init(Bundle savedInstanceState) {
 
        // add first account
        GAccount account = new GAccount("NeoKree","neokree@gmail.com",this.getResources().getDrawable(R.drawable.photo),this.getResources().getDrawable(R.drawable.bamboo));
        this.addAccount(account);
 
        // set listener
        this.setAccountListener(this);
 
        // add your sections
        this.addSection(this.newSection("Section 1",new FragmentIndex()));
        this.addSection(this.newSection("Section 2",new FragmentIndex()));
        this.addDivisor();
        this.addSection(this.newSection("Recorder",this.getResources().getDrawable(R.drawable.ic_mic_white_24dp),new FragmentIndex()).setNotifications(10));
 
        // add custom colored section with icon
        this.addSection(this.newSection("Night Section"this.getResources().getDrawable(R.drawable.ic_hotel_grey600_24dp), new FragmentIndex())
                .setSectionColor(Color.parseColor("#2196f3")).setNotifications(150)); // material blue 500
 
        this.addDivisor();
        // add custom colored section with only text
        this.addSection(this.newSection("Last Section"new FragmentIndex()).setSectionColor((Color.parseColor("#ff9800")))); // material orange 500
 
        Intent i = new Intent(this,Settings.class);
        this.addSection(this.newSection("Settings",this.getResources().getDrawable(R.drawable.ic_settings_black_24dp),i));
 
    }
 
}

注意不要重写OnCreate,而是重写init方法。

 

主题样式设置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<resources>    <!-- Base application theme. -->
    <style name="AppTheme" parent="GoogleNavigationDrawerTheme">        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/light_blue_500</item>
        <item name="colorAccent">@color/grey_1000</item>
    </style>    <!-- Light version theme. -->
    <style name="AppTheme" parent="GoogleNavigationDrawerTheme.Light">        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/light_blue_500</item>
        <item name="colorAccent">@color/grey_1000</item>
    </style>    <!-- Light version with Black actionbar -->
    <style name="AppTheme" parent="GoogleNavigationDrawerTheme.Light.DarkActionBar">        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/light_blue_500</item>
        <item name="colorAccent">@color/grey_1000</item>
    </style>
 
</resources>

posted on 2015-04-09 09:17  wasdchenhao  阅读(162)  评论(0)    收藏  举报

导航