博客
关于我
Android滑动导航菜单的快速构建
阅读量:108 次
发布时间:2019-02-26

本文共 1042 字,大约阅读时间需要 3 分钟。

李济洲作为我们公众号的“老司机”,今天就由他来带大家学习如何快速构建导航菜单。他的博客内容分为上下两篇,我们这里整合成一篇,希望不要超载。

李济洲的博客地址是:http://blog.csdn.net/leejizhou

滑动导航菜单一直是移动App中流行的UI设计,随着Material Design的盛行,Android开发中这种设计越来越普遍。今天我们将总结如何利用Android API快速构建各种类型的滑动导航菜单效果。

第一种样式是QQ客户端V6版本的滑动菜单效果。实现这个UI效果需要利用V4包的SlidingPaneLayout控件,这是一个帮助开发者实现水平多层滑动的布局控件,继承自ViewGroup。SlidingPaneLayout的主要方法包括setParallaxDistance、setCoveredFadeColor、setSliderFadeColor、setPanelSlideListener、openPane和closePane等。

第二种样式是主视图不动,边缘划出菜单效果。这需要使用V4包的DrawerLayout布局容器。DrawerLayout和SlidingPaneLayout都利用了V4的ViewDragHelper来实现滑动效果。DrawerLayout的主要方法包括addDrawerListener、openDrawer、closeDrawer和isDrawerOpen等。

当下的设计标准

在Material Design之前,官方对滑动导航菜单的设计标准是将菜单布局放在ActionBar下方。然而,随着Android 5.0 Material Design的推出,官方对滑动导航菜单的设计标准有了重大调整。新的标准化设计要求滑动导航菜单一跃来至所有界面的顶端。

与DrawerLayout配合使用的NavigationView是实现标准设计的滑动导航菜单的最佳选择。NavigationView需要在XML布局中设置android:layout_gravity="start"或"end",并通过app:headerLayout属性传入导航菜单的头部布局。NavigationView在Design库中需要添加相应的依赖库:compile 'com.android.support:design:24.0.0'。

如果你有好的技术文章想和大家分享,欢迎向我的公众号投稿,投稿具体细节请在公众号主页点击“投稿”菜单查看。

你可能感兴趣的文章
nowcoder—Beauty of Trees
查看>>
np.arange()和np.linspace()绘制logistic回归图像时得到不同的结果?
查看>>
np.power的使用
查看>>
NPM 2FA双重认证的设置方法
查看>>
npm build报错Cannot find module ‘webpack/lib/rules/BasicEffectRulePlugin‘解决方法
查看>>
npm build报错Cannot find module ‘webpack‘解决方法
查看>>
npm ERR! ERESOLVE could not resolve报错
查看>>
npm ERR! fatal: unable to connect to github.com:
查看>>
npm ERR! Unexpected end of JSON input while parsing near '...on":"0.10.3","direc to'
查看>>
npm ERR! Unexpected end of JSON input while parsing near ‘...“:“^1.2.0“,“vue-html-‘ npm ERR! A comp
查看>>
npm error Missing script: “server“npm errornpm error Did you mean this?npm error npm run serve
查看>>
npm error MSB3428: 未能加载 Visual C++ 组件“VCBuild.exe”。要解决此问题,1) 安装
查看>>
npm install CERT_HAS_EXPIRED解决方法
查看>>
npm install digital envelope routines::unsupported解决方法
查看>>
npm install 卡着不动的解决方法
查看>>
npm install 报错 EEXIST File exists 的解决方法
查看>>
npm install 报错 ERR_SOCKET_TIMEOUT 的解决方法
查看>>
npm install 报错 Failed to connect to github.com port 443 的解决方法
查看>>
npm install 报错 fatal: unable to connect to github.com 的解决方法
查看>>
npm install 报错 no such file or directory 的解决方法
查看>>