学习福利
【Android 详细知识点思维脑图(技能树)】
其实Android开发的知识点就那么多,面试问来问去还是那么点东西。所以面试没有其他的诀窍,只看你对这些知识点准备的充分程度。so,出去面试时先看看自己复习到了哪个阶段就好。
虽然 Android 没有前几年火热了,已经过去了会四大组件就能找到高薪职位的时代了。这只能说明 Android 中级以下的岗位饱和了,现在高级工程师还是比较缺少的,很多高级职位给的薪资真的特别高(钱多也不一定能找到合适的),所以努力让自己成为高级工程师才是最重要的。
这里附上上述的面试题相关的几十套字节跳动,京东,小米,腾讯、头条、阿里、美团等公司19年的面试题。把技术点整理成了视频和PDF(实际上比预期多花了不少精力),包含知识脉络 + 诸多细节。
由于篇幅有限,这里以图片的形式给大家展示一小部分。
网上学习 Android的资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。希望这份系统化的技术体系对大家有一个方向参考。
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
=========================================================================================
在开发过程中经常能遇到一些复杂的UI,可能会出现布局嵌套过多的问题,嵌套得越多,设备绘制视图所需的时间和计算功耗也就越多,ConstraintLayout使用起来比RelativeLayout更灵活,可以按照比例约束控件位置和尺寸。
============================================================================================
layout_constraintTop_toTopOf // 将所需视图的顶部与另一个视图的顶部对齐。
layout_constraintTop_toBottomOf // 将所需视图的顶部与另一个视图的底部对齐。
layout_constraintBottom_toTopOf // 将所需视图的底部与另一个视图的顶部对齐。
layout_constraintBottom_toBottomOf // 将所需视图的底部与另一个视图的底部对齐。
layout_constraintLeft_toTopOf // 将所需视图的左侧与另一个视图的顶部对齐。
layout_constraintLeft_toBottomOf // 将所需视图的左侧与另一个视图的底部对齐。
layout_constraintLeft_toLeftOf // 将所需视图的左边与另一个视图的左边对齐。
layout_constraintLeft_toRightOf // 将所需视图的左边与另一个视图的右边对齐。
layout_constraintRight_toTopOf // 将所需视图的右对齐到另一个视图的顶部。
layout_constraintRight_toBottomOf // 将所需视图的右对齐到另一个视图的底部。
layout_constraintRight_toLeftOf // 将所需视图的右边与另一个视图的左边对齐。
layout_constraintRight_toRightOf // 将所需视图的右边与另一个视图的右边对齐。
在ConstraintLayout中,还可以将宽定义成高的一个比例或者高定义成宽的比率。首先,需要将宽或者高设置为0dp(即MATCH_CONSTRAINT),即要适应约束条件。然后通过layout_constraintDimensionRatio属性设置一个比率即可。这个比率可以是一个浮点数,表示宽度和高度之间的比率;也可以是“宽度:高度”形式的比率。比如:
<?xml version="1.0" encoding="utf-8"?><androidx.constraintlayout.widget.ConstraintLayout 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”>
<Button
android:layout_width=“wrap_content”
android:layout_height=“0dp”
android:text=“-------------------宽高比1:1-------------------”
app:layout_constraintBottom_toBottomOf=“parent”
app:layout_constraintDimensionRatio=“1:1”
app:layout_constraintLeft_toLeftOf=“parent”
app:layout_constraintRight_toRightOf=“parent”
app:layout_constraintTop_toTopOf=“parent” />
</androidx.constraintlayout.widget.ConstraintLayout>
4.1.1app:layout_constraintDimensionRatio=“h,?:?”
设置该属性时,确保android:layout_height=“0dp”
即表示高度随着宽度在变化,例如:
app:layout_constraintDimensionRatio=“h,2:1” //高度是宽度的1/2
<Button
android:layout_width=“200dp”
android:layout_height=“0dp”
app:layout_constraintBottom_toBottomOf=“parent”
app:layout_constraintDimensionRatio=“h,2:1”
app:layout_constraintLeft_toLeftOf=“parent”
app:layout_constraintRight_toRightOf=“parent”
app:layout_constraintTop_toTopOf=“parent” />
4.1.2app:layout_constraintDimensionRatio=“w,?:?”
设置该属性时,确保android:layout_width=“0dp”
即表示宽度随着高度在变化,例如:
app:layout_constraintDimensionRatio=“w,1:2” //宽度是高度的1/2
<Button
android:layout_width=“0dp”
android:layout_height=“200dp”
app:layout_constraintBottom_toBottomOf=“parent”
app:layout_constraintDimensionRatio=“w,1:2”
app:layout_constraintLeft_toLeftOf=“parent”
app:layout_constraintRight_toRightOf=“parent”
app:layout_constraintTop_toTopOf=“parent” />
LinearLayout中可以设置权重,ConstraintLayout同样也有这玩意。
通过设置以下两个属性:
app:layout_constraintHorizontal_weight //水平权重
app:layout_constraintVertical_weight //竖直权重
例如:
<?xml version="1.0" encoding="utf-8"?><androidx.constraintlayout.widget.ConstraintLayout 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”>
<Button
android:id=“@+id/btn_1”
android:layout_width=“0dp”
android:layout_height=“wrap_content”
android:text=“权重为1”
app:layout_constraintHorizontal_weight=“1”
app:layout_constraintLeft_toLeftOf=“parent”
app:layout_constraintRight_toLeftOf=“@id/btn_2”
app:layout_constraintTop_toTopOf=“parent” />
<Button
android:id=“@+id/btn_2”
android:layout_width=“0dp”
android:layout_height=“wrap_content”
android:text=“权重为1”
app:layout_constraintHorizontal_weight=“1”
app:layout_constraintLeft_toRightOf=“@id/btn_1”
app:layout_constraintRight_toLeftOf=“@id/btn_3”
app:layout_constraintTop_toTopOf=“parent” />
<Button
android:id=“@+id/btn_3”
android:layout_width=“0dp”
android:layout_height=“wrap_content”
android:text=“权重为2”
app:layout_constraintHorizontal_weight=“2”
app:layout_constraintLeft_toRightOf=“@id/btn_2”
app:layout_constraintRight_toRightOf=“parent”
app:layout_constraintTop_toTopOf=“parent” />
</androidx.constraintlayout.widget.ConstraintLayout>
官网上一共有5种样式的链:
有三种可选参数:
- spread:将可用空间以均匀分布的方式将视图放置在链中(默认模式):
- spread_inside:将链中最外面的视图对齐到外边缘,然后在可用空间内均匀的放置链中视图:
- packed:将链中的视图紧紧的放在一起(可以提供边距让其分开),然后让其居中在可用空间内:
Guideline是只能用在ConstraintLayout布局里面的一个工具类,用于辅助布局,类似为辅助线,可以设置android:orientation属性来确定是横向的还是纵向的。
-
设置为vertical的时候,Guideline的宽度为0,高度是parent也就是ConstraintLayout的高度
-
设置为horizontal的时候,Guideline的高度为0,宽度是parent的宽度
Guideline的属性:
- layout_constraintGuide_begin,指定左侧(方向为vertical)或顶部(方向为horizontal)的固定距离,如10dp,在距离左侧或者顶部10dp的位置会出现一条辅助线
- layout_constraintGuide_end,指定右侧(方向为vertical)或底部(方向为horizontal)的固定距离,如50dp,在距离右侧或底部50dp的位置会出现一条辅助线
- layout_constraintGuide_percent,指定在父控件中的宽度或高度的百分比,如0.5,表示距离顶部或者左侧的50%的距离。
举例:
<?xml version="1.0" encoding="utf-8"?><androidx.constraintlayout.widget.ConstraintLayout 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”>
<Button
android:id=“@+id/button4”
android:layout_width=“0dp”
android:layout_height=“wrap_content”
android:text=“权重为1”
app:layout_constraintHorizontal_weight=“1”
app:layout_constraintLeft_toLeftOf=“parent”
app:layout_constraintRight_toLeftOf=“@id/button5”
app:layout_constraintTop_toTopOf=“parent” />
<Button
android:id=“@+id/button5”
android:layout_width=“0dp”
android:layout_height=“wrap_content”
android:layout_marginTop=“340dp”
android:text=“权重为2”
app:layout_constraintHorizontal_weight=“2”
app:layout_constraintLeft_toRightOf=“@id/button4”
app:layout_constraintRight_toLeftOf=“@id/button6”
app:layout_constraintTop_toTopOf=“parent” />
<Button
android:id=“@+id/button6”
android:layout_width=“0dp”
android:layout_height=“wrap_content”
android:text=“权重为1”
app:layout_constraintHorizontal_weight=“1”
app:layout_constraintLeft_toRightOf=“@id/button5”
app:layout_constraintRight_toRightOf=“parent”
app:layout_constraintTop_toTopOf=“parent” />
<androidx.constraintlayout.widget.Guideline
android:id=“@+id/guideline”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:orientation=“horizontal”
app:layout_constraintGuide_percent=“0.5” />
<androidx.constraintlayout.widget.Guideline
android:id=“@+id/guideline2”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:orientation=“vertical”
app:layout_constraintGuide_percent=“0.5” />
</androidx.constraintlayout.widget.ConstraintLayout>
无约束:
点击箭头所指:
visibility可选值:
- invisible:不可见(但是位置还占着)
- visible:可见
- gone:不可见(无占位)
=========================================================================
<?xml version="1.0" encoding="utf-8"?><androidx.constraintlayout.widget.ConstraintLayout 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”>
<ImageView
android:id=“@+id/imageView”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_marginStart=“28dp”
android:layout_marginTop=“32dp”
app:layout_constraintStart_toStartOf=“parent”
app:layout_constraintTop_toTopOf=“parent”
app:srcCompat=“@drawable/touxiang” />
<TextView
android:id=“@+id/textView”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_marginStart=“20dp”
android:layout_marginTop=“40dp”
android:text=“老实人兰奥”
android:textColor=“@color/black”
app:layout_constraintStart_toEndOf=“@+id/imageView”
app:layout_constraintTop_toTopOf=“parent” />
<TextView
android:id=“@+id/textView2”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_marginTop=“10dp”
android:text=“微信号:lanaolaoshiren”
app:layout_constraintStart_toStartOf=“@+id/textView”
app:layout_constraintTop_toBottomOf=“@+id/textView” />
<ImageView
android:id=“@+id/imageView3”
android:layout_width=“48dp”
android:layout_height=“44dp”
android:layout_marginStart=“28dp”
android:layout_marginTop=“40dp”
app:layout_constraintStart_toStartOf=“parent”
app:layout_constraintTop_toBottomOf=“@+id/imageView”
app:srcCompat=“@drawable/zhifu” />
<TextView
android:id=“@+id/textView5”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
最后
其实Android开发的知识点就那么多,面试问来问去还是那么点东西。所以面试没有其他的诀窍,只看你对这些知识点准备的充分程度。so,出去面试时先看看自己复习到了哪个阶段就好。
当然我也为你们整理好了百度、阿里、腾讯、字节跳动等等互联网超级大厂的历年面试真题集锦。这也是我这些年来养成的习惯,一定要学会把好的东西,归纳整理,然后系统的消化吸收,这样才能极大的提高学习效率和成长进阶。碎片、零散化的东西,我觉得最没有价值的。就好比你给我一张扑克牌,我只会觉得它是一张废纸,但如果你给我一副扑克牌,它便有了它的价值。这和我们收集资料就要收集那些系统化的,是一个道理。
网上学习 Android的资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。希望这份系统化的技术体系对大家有一个方向参考。
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
:layout_height=“wrap_content”
最后
其实Android开发的知识点就那么多,面试问来问去还是那么点东西。所以面试没有其他的诀窍,只看你对这些知识点准备的充分程度。so,出去面试时先看看自己复习到了哪个阶段就好。
当然我也为你们整理好了百度、阿里、腾讯、字节跳动等等互联网超级大厂的历年面试真题集锦。这也是我这些年来养成的习惯,一定要学会把好的东西,归纳整理,然后系统的消化吸收,这样才能极大的提高学习效率和成长进阶。碎片、零散化的东西,我觉得最没有价值的。就好比你给我一张扑克牌,我只会觉得它是一张废纸,但如果你给我一副扑克牌,它便有了它的价值。这和我们收集资料就要收集那些系统化的,是一个道理。
[外链图片转存中…(img-5CB2sF5C-1715653905786)]
网上学习 Android的资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。希望这份系统化的技术体系对大家有一个方向参考。
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!