分享到:
点击次数:333  更新时间:2016-10-11 16:24:04  【打印此页】  【关闭
澳门新濠天地娱乐场澳门新濠天地娱乐定制
当前位置:主页 > 新闻动态 > 技术交流 > material design风格的导航抽屉Activity:MaterialNavigationDrawer

material design风格的导航抽屉Activity:MaterialNavigationDrawer

责任编辑:admin 发布时间:2016-11-02 10:59 浏览次数:

拥有material design风格和简单方法的导航抽屉Activity。
It requires 11+ API and android support v7 (Toolbar)
Download example apk
How to add to your project
In your Activity...
public class MyActivity extends MaterialNavigationDrawer {
    @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",new FragmentIndex()));
        this.addSection(this.newSection("Section 2",new FragmentIndex()));
        this.addDivisor();
        this.addSection(this.newSection("Section 2",this.getResources().getDrawable(R.drawable.section2),new FragmentIndex()));
        this.addBottomSection(this.newBottomSection("Settings",this.getResources().getDrawable(R.drawable.settings),new FragmentSettings()));
    }
}
In your styles.xml
<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>
N.B. Not override OnCreate method! Use init method instead.
How to import
Android Studio
Add this to your build.gradle:
repositories {
    mavenCentral()
}
dependencies {
    compile 'it.neokree:MaterialNavigationDrawer:1.1'