在这个页面中直接找到design这个依赖,点击后再点击这两个窗口上的OK按钮,等待编译完成就完成导入了!
(可能版本不一样,导入即可)
13.1.5 介绍NavigationView
Google在5.0之后推出的NavitationView,所有的布局控件放在DrawerLayout中来使用,NavigationView的作用就像这样,实现侧拉效果。和DrawerLayout效果几分差异,QQ从左至右从边滑动的侧拉效果。上半部分图片背景,圆形头像,下面每一个都是导航菜单现在就来实现一下它(虽然是Iphone图,但是没关系了,就是这个道理)。
布局文件、标签属性
敲出最简单的布局,实现最简单的效果
<?xml version="1.0" encoding="utf-8"?><android.support.v4.widget.DrawerLayout xmlns:android=“http://schemas.android.com/apk/res/android”
xmlns:app=“http://schemas.android.com/apk/res-auto”
xmlns:tools=“http://schemas.android.com/tools”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
tools:context=“.MainActivity”>
<LinearLayout
android:background=“#4d7aed”
android:layout_width=“match_parent”
android:layout_height=“match_parent”>
<TextView
android:gravity=“center”
android:textSize=“18sp”
android:text=“这里是一个主页面”
android:layout_width=“match_parent”
android:layout_height=“match_parent” />
<android.support.design.widget.NavigationView
android:layout_gravity=“left”
android:background=“#ffffff”
android:layout_width=“match_parent”
android:layout_height=“match_parent”>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
将所有布局控件放下DrawerLayout 中,NavigationView加上属性android:layout_gravity="left"实现左侧滑!
如果加一个头布局文件,姐可以侧拉出这样的效果布局代码如下
主布局文件activity_main.xml:
<?xml version="1.0" encoding="utf-8"?><android.support.v4.widget.DrawerLayout xmlns:android=“http://schemas.android.com/apk/res/android”
xmlns:app=“http://schemas.android.com/apk/res-auto”
xmlns:tools=“http://schemas.android.com/tools”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
tools:context=“.MainActivity”>
<LinearLayout
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:background=“#4d7aed”>
<TextView
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:gravity=“center”
android:text=“这里是一个主页面”
android:textSize=“18sp” />
<android.support.design.widget.NavigationView
app:headerLayout=“@layout/layout”
android:layout_width=“450dp”
android:layout_height=“match_parent”
android:layout_gravity=“start”
android:background=“#ffffff”>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
头布局文件layout.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”
android:layout_width=“match_parent”
android:layout_height=“260dp”
android:orientation=“vertical”>
<ImageView
android:layout_width=“match_parent”
android:layout_height=“230dp”
android:background=“@mipmap/kb” />
<TextView
android:layout_width=“match_parent”
android:layout_height=“30dp”
android:background=“#63a6e9”
android:gravity=“center”
android:text=“《魁拔》”
android:textColor=“#fff”
android:textSize=“18sp” />
之后加上menu就可以实现这样的效果了(虽然丑了,但是还是可以实现,要求美观就细扣)
创建的menu应该在这里
menu.xml
<?xml version="1.0" encoding="utf-8"?><item
android:id=“@+id/item1”
android:title=“功能列表1”>
<item
android:id=“@+id/item2”
android:title=“功能列表2”>
<item
android:id=“@+id/item3”
android:title=“功能列表3”>
<item
android:id=“@+id/item4”
android:title=“功能列表4”>
<item
android:id=“@+id/item5”
android:title=“功能列表5”>
还可以在每个item加上 android:icon=“” ,为这个item设置上图标
布局文件
<?xml version="1.0" encoding="utf-8"?><android.support.v4.widget.DrawerLayout xmlns:android=“http://schemas.android.com/apk/res/android”
xmlns:app=“http://schemas.android.com/apk/res-auto”
xmlns:tools=“http://schemas.android.com/tools”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
tools:context=“.MainActivity”>
<LinearLayout
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:background=“#4d7aed”>
<TextView
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:gravity=“center”
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数初中级Android工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则近万的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:Android)
![](https://img-blog.csdnimg.cn/img_convert/7cb3f12a37d4887a9893c89bbd1f4f8b.jpeg)
最后
**一个零基础的新人,我认为坚持是最最重要的。**我的很多朋友都找我来学习过,我也很用心的教他们,可是不到一个月就坚持不下来了。我认为他们坚持不下来有两点主要原因:
他们打算入行不是因为兴趣,而是因为所谓的IT行业工资高,或者说完全对未来没有任何规划。
刚开始学的时候确实很枯燥,这确实对你是个考验,所以说坚持下来也很不容易,但是如果你有兴趣就不会认为这是累,不会认为这很枯燥,总之还是贵在坚持。
技术提升遇到瓶颈了?缺高级Android进阶视频学习提升自己吗?还有大量大厂面试题为你面试做准备!
提升自己去挑战一下BAT面试难关吧
对于很多Android工程师而言,想要提升技能,往往是自己摸索成长,不成体系的学习效果低效漫长且无助。整理的这些知识图谱希望对Android开发的朋友们有所参考以及少走弯路,本文的重点是你有没有收获与成长,其余的都不重要,希望读者们能谨记这一点。
不论遇到什么困难,都不应该成为我们放弃的理由!
如果有什么疑问的可以直接私我,我尽自己最大力量帮助你!
最后祝各位新人都能坚持下来,学有所成。
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!
面试题为你面试做准备!**
提升自己去挑战一下BAT面试难关吧
[外链图片转存中…(img-ONsHMvD4-1713588218962)]
对于很多Android工程师而言,想要提升技能,往往是自己摸索成长,不成体系的学习效果低效漫长且无助。整理的这些知识图谱希望对Android开发的朋友们有所参考以及少走弯路,本文的重点是你有没有收获与成长,其余的都不重要,希望读者们能谨记这一点。
不论遇到什么困难,都不应该成为我们放弃的理由!
如果有什么疑问的可以直接私我,我尽自己最大力量帮助你!
最后祝各位新人都能坚持下来,学有所成。
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!