-
Layout File Name:文件名后面不用写".xml"。
-
Root Tag :默认是线性布局,可以改成其他布局。
====================================================================
orientation属性
线性布局里的orientation是一个很重要的属性,表示控件的排列方向。该属性存在两个值,vertical(垂直)和horizontal(水平)。
例子1:
<?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=“match_parent”
android:orientation=“vertical” >
<Button android:id="@+id/button"
android:layout_width=“200dp”
android:layout_height=“wrap_content”
android:text=“B1” />
<Button android:id="@+id/button2"
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:text=“B2” />
结果:
上面例子1中的两个按钮是垂直排列。
而如果将orientation的值改为horizontal(水平排列),则效果为:
layout_width,layout_height,layout_weight
layout_width:宽度,可以设值任意的确定值(填写数值后面+“dp”,如:“200dp”),也可以写成wrap_content或match_parent
layout_height :高度。
wrap_content :指示您的视图将其大小调整为内容所需的尺寸,可以理解为默认大小。
match_parent :指示您的视图尽可能采用其父视图组所允许的最大尺寸。
效果还是如例子1。
layout_weight:直接填写数值(不用+“dp”),可以理解为权重或占比。
例子2:
<?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=“match_parent”
android:orientation=“horizontal” >
<Button android:id="@+id/button"
android:layout_width=“0dp”
android:layout_height=“wrap_content”
android:layout_weight=“1”
android:text=“B1” />
<Button android:id="@+id/button2"
android:layout_width=“0dp”
android:layout_height=“wrap_content”
android:layout_weight=“1”
android:text=“B2” />
例子2中,存在两个按钮,layout_weight都属性设为1,就是两个按钮中每个占据了1/2。同理,如果三个按钮,则每个按钮占据1/3。
如果两个按钮中,layout_weight值分别为1和2,则占据1/3和2/3。如图:
需要注意,以上例子都是在orientation=“horizontal” 且Button的layout_width="0dp"时 。如果orientation=“vertical”,则需将layout_height=“0dp”
layout_gravity和gravity
layout_gravity: 控件位于屏幕的位置
gravity: 控件的内容位于控件的位置
如例子3:
<LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:orientation=“vertical” >
<LinearLayout
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:orientation=“vertical”>
<Button android:id="@+id/button"
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:text=“B1” />
<Button android:id="@+id/button2"
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_gravity=“right”
android:gravity=“left”
android:text=“B2” />
其中Button2的 android:layout_gravity=“right”,android:gravity=“left”
就是Button2位于屏幕的右方,内容“B2”在控件中左对齐。
============================================================================
适配器也存在很多种,这次添加的是SimpleAdapter适配器。
首先需要一个主布局main.xml承载一个ListView
<?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=“match_parent”>
<ListView
android:id="@+id/listView"
android:layout_width=“match_parent”
android:layout_height=“match_parent”>
最后
都说三年是程序员的一个坎,能否晋升或者提高自己的核心竞争力,这几年就十分关键。
技术发展的这么快,从哪些方面开始学习,才能达到高级工程师水平,最后进阶到Android架构师/技术专家?我总结了这 5大块;
我搜集整理过这几年阿里,以及腾讯,字节跳动,华为,小米等公司的面试题,把面试的要求和技术点梳理成一份大而全的“ Android架构师”面试 PDF(实际上比预期多花了不少精力),包含知识脉络 + 分支细节。
Java语言与原理;
大厂,小厂。Android面试先看你熟不熟悉Java语言
高级UI与自定义view;
自定义view,Android开发的基本功。
性能调优;
数据结构算法,设计模式。都是这里面的关键基础和重点需要熟练的。
NDK开发;
未来的方向,高薪必会。
前沿技术;
组件化,热升级,热修复,框架设计
网上学习 Android的资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。希望这份系统化的技术体系对大家有一个方向参考。
我在搭建这些技术框架的时候,还整理了系统的高级进阶教程,会比自己碎片化学习效果强太多,GitHub可见;《Android架构视频+学习笔记》
当然,想要深入学习并掌握这些能力,并不简单。关于如何学习,做程序员这一行什么工作强度大家都懂,但是不管工作多忙,每周也要雷打不动的抽出 2 小时用来学习。
不出半年,你就能看出变化!
记》](https://github.com/a120464/Android-P7/blob/master/Android%E5%BC%80%E5%8F%91%E4%B8%8D%E4%BC%9A%E8%BF%99%E4%BA%9B%EF%BC%9F%E5%A6%82%E4%BD%95%E9%9D%A2%E8%AF%95%E6%8B%BF%E9%AB%98%E8%96%AA%EF%BC%81.md)**
当然,想要深入学习并掌握这些能力,并不简单。关于如何学习,做程序员这一行什么工作强度大家都懂,但是不管工作多忙,每周也要雷打不动的抽出 2 小时用来学习。
不出半年,你就能看出变化!