2024年Android最新Android开发学习笔记之详解五大布局,安卓直播开发面试

学习分享

在当下这个信息共享的时代,很多资源都可以在网络上找到,只取决于你愿不愿意找或是找的方法对不对了

很多朋友不是没有资料,大多都是有几十上百个G,但是杂乱无章,不知道怎么看从哪看起,甚至是看后就忘

如果大家觉得自己在网上找的资料非常杂乱、不成体系的话,我也分享一套给大家,比较系统,我平常自己也会经常研读。

2021最新上万页的大厂面试真题

七大模块学习资料:如NDK模块开发、Android框架体系架构…

只有系统,有方向的学习,才能在段时间内迅速提高自己的技术。

这份体系学习笔记,适应人群:
**第一,**学习知识比较碎片化,没有合理的学习路线与进阶方向。
**第二,**开发几年,不知道如何进阶更进一步,比较迷茫。
第三,到了合适的年纪,后续不知道该如何发展,转型管理,还是加强技术研究。如果你有需要,我这里恰好有为什么,不来领取!说不定能改变你现在的状态呢!
由于文章内容比较多,篇幅不允许,部分未展示内容以截图方式展示

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化学习资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

AbsoluteLayout(绝对布局)

FrameLayout(框架布局)

利用这五种布局,可以在屏幕上将控件随心所欲的摆放,而且控件的大小和位置会随着屏幕大小的变化作出相应的调整。下面是这五个布局在View的继承体系中的关系:

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

一,LinearLayout(线性布局)

在一个方向上(垂直或水平)对齐所有子元素

一个垂直列表每行将只有一个子元素(无论它们有多宽)

一个水平列表只是一列的高度(最高子元素的高度来填充)

下面是一个简单的线性布局的例子:

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

  1. 01 <?xml version="1.0" encoding="utf-8"?>

  2. 02 <LinearLayout

  3. 03 xmlns:android=“http://schemas.android.com/apk/res/android”

  4. 04 android:layout_width=“match_parent”

  5. 05 android:layout_height=“match_parent” android:orientation=“vertical”>

  6. 06 <EditText android:text=“EditText”

  7. 07

  8. 08 android:id=“@+id/editText1”

  9. 09

  10. 10 android:layout_height=“wrap_content”

  11. 11

  12. 12 android:layout_width=“fill_parent”>

  13. 13

  14. 14

  15. 15 <LinearLayout android:id=“@+id/linearLayout1”

  16. 16

  17. 17 android:layout_height=“fill_parent”

  18. 18

  19. 19 android:layout_width=“fill_parent”

  20. 20

  21. 21 android:gravity=“right”>

  22. 22 <Button android:id=“@+id/button2”

  23. 23

  24. 24 android:text=“Button”

  25. 25

  26. 26 android:layout_width=“wrap_content”

  27. 27

  28. 28 android:layout_height=“wrap_content”>

  29. 29 <Button android:text=“Button”

  30. 30

  31. 31 android:id=“@+id/button1”

  32. 32

  33. 33 android:layout_width=“wrap_content”

  34. 34

  35. 35 android:layout_height=“wrap_content”>

  36. 36

  37. 37

复制代码

最外层布局为垂直线性布局,宽度为整个屏幕(fill_parent),高度为刚好适合子控件(wrap_content)。然后依次添加一个EditText,一个水平布局的LinearLayout,在这个线性布局里面,摆放两个Button,该线性布局的gravity属性设置为”right”,所以里面的两个Button靠右显示。

二,TableLayout(表格布局)

把子元素放入到行与列中

不显示行、列或是单元格边界线

单元格不能横跨行,如HTML中一样

表格布局模型以行列的形式管理子控件,每一行为一个TableRow的对象,当然也可以是一个View的对象。TableRow可以添加子控件,每添加一个为一列。

android:layout_colum官方解释:The index of the column in which this child should be,也即是设置该控件在TableRow中所处的列。

android:layout_span官方解释:Defines how many columns this child should span,也即是设置该控件所跨越的列数。

android:collapseColumns官方解释:The 0 based index of the columns to collapse. The column indices must be separated by a comma: 1, 2, 5.也即是将TableLayout里面指定的列隐藏,若有多列需要隐藏,请用逗号将需要隐藏的列序号隔开。

android:stretchColumns官方解释:The 0 based index of the columns to stretch. The column indices must be separated by a comma: 1, 2, 5. You can stretch all columns by using the value “*” instead. Note that a column can be marked stretchable and shrinkable at the same time.也即是设置指定的列为可伸展的列,可伸展的列会尽量伸展以填满所有可用的空间,若有多列需要设置为可伸展,请用逗号将需要伸展的列序号隔开。

android:shrinkColumns官方解释:The 0 based index of the columns to shrink. The column indices must be separated by a comma: 1, 2, 5. You can shrink all columns by using the value “*” instead. 设置指定的列为可收缩的列。当可收缩的列太宽以至于让其他列显示不全时,会纵向延伸空间。当需要设置多列为可收缩时,将列序号用逗号隔开。

下面用一个例子简单说明TableLayout的用法:

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

  1. 01 <?xml version="1.0" encoding="utf-8"?>

  2. 02 <TableLayout xmlns:android=“http://schemas.android.com/apk/res/android”

  3. 03 android:layout_width=“fill_parent”

  4. 04 android:layout_height=“fill_parent”

  5. 05 android:stretchColumns=“1”>

  6. 06

  7. 07 <TextView

  8. 08 android:layout_column=“1”

  9. 09 android:padding=“3dip” android:text=“Row1”/>

  10. 10 <TextView

  11. 11 android:text=“1”

  12. 12 android:gravity=“right”

  13. 13 android:padding=“3dip” />

  14. 14

  15. 15 <View

  16. 16 android:layout_height=“2dip”

  17. 17 android:background=“#FF909090” />

  18. 18

  19. 19 <TextView

  20. 20 android:text=“*”

  21. 21 android:padding=“3dip” />

  22. 22 <TextView

  23. 23 android:text=“Row12”

  24. 24 android:padding=“3dip” />

  25. 25 <TextView

  26. 26 android:text=“2”

  27. 27 android:gravity=“right”

  28. 28 android:padding=“3dip” />

  29. 29

  30. 30 <View

  31. 31 android:layout_height=“2dip”

  32. 32 android:background=“#FF909090” />

  33. 33

  34. 34 <TextView

  35. 35 android:layout_column=“1”

  36. 36 android:text=“Row13”

  37. 37 android:padding=“3dip” />

  38. 38

  39. 39

复制代码

三、RelativeLayout(相对布局)

相对布局的子控件会根据它们所设置的参照控件和参数进行相对布局。参照控件可以是父控件,也可以是其它子控件,但是被参照的控件必须要在参照它的控件之前定义。下面是一个简单的例子:

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

  1. 01 <?xml version="1.0" encoding="utf-8"?>

  2. 02 <?xml version="1.0" encoding="utf-8"?>

  3. 03 <RelativeLayout xmlns:android=“http://schemas.android.com/apk/res/android”

  4. 04 android:layout_width=“fill_parent”

  5. 05 android:layout_height=“fill_parent”

  6. 06 >

  7. 07 <AnalogClock

  8. 08 android:id=“@+id/aclock”

  9. 09 android:layout_width=“wrap_content”

  10. 10 android:layout_height=“wrap_content”

  11. 11 android:layout_centerInParent=“true” />

  12. 12 <DigitalClock

  13. 13 android:id=“@+id/dclock”

  14. 14 android:layout_width=“wrap_content”

  15. 15 android:layout_height=“wrap_content”

  16. 16 android:layout_below=“@id/aclock”

  17. 17 android:layout_alignLeft=“@id/aclock”

  18. 18 android:layout_marginLeft=“40px” />

  19. 19 <TextView

  20. 20 android:layout_width=“wrap_content”

  21. 21 android:layout_height=“wrap_content”

  22. 22 android:text=“当前时间:”

  23. 23 android:layout_toLeftOf=“@id/dclock”

  24. 24 android:layout_alignTop=“@id/aclock”/>

  25. 25

复制代码

最后

我这里整理了一份完整的学习思维以及Android开发知识大全PDF。

当然实践出真知,即使有了学习线路也要注重实践,学习过的内容只有结合实操才算是真正的掌握。

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化学习资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

"

  1. 23 android:layout_toLeftOf=“@id/dclock”

  2. 24 android:layout_alignTop=“@id/aclock”/>

  3. 25

复制代码

最后

我这里整理了一份完整的学习思维以及Android开发知识大全PDF。

[外链图片转存中…(img-yf4QIwZi-1715658890169)]

当然实践出真知,即使有了学习线路也要注重实践,学习过的内容只有结合实操才算是真正的掌握。

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化学习资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

  • 22
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值