一、容器(布局)

1.1 LinearLayout

(1)属性

notion image

(2)示例

  • 其例子的用法如下所示:

1.2 RelativeLayout

(1)属性

notion image
notion image

(2)示例

1.3 FrameLayout

(1)属性

notion image

(2)特点

  • 所创建的同级的FrameLayout布局是分布在相同的位置上,若两者大小相同,则后者会将前者覆盖

(3)示例

1.4 TableLayout

(1)特点

  • 该布局下的每个占用一行
  • 若想要求两个按钮或其他放在一行内,需将这些放置在<TableRow></TableRow>下,而<TableRow><TableLayout>

(2)属性

notion image

(3)示例

notion image

1.5 GridLayout

(1)属性

notion image
notion image

(2)示例

1.6 ConstraintLayout

(1)特点

  • 约束布局

二、控件

2.1 TextView

(1)属性

notion image
notion image
notion image

2.2 Button

(1)本质

  • 继承于 TextView
  • 其属性同 TextView 一样

(2)示例

(3)事件处理

  • 点击事件
  • 长按事件
  • 触摸事件

2.3 StateListDrawable(不是控件)

(1)属性

notion image

(2)设置背景示例(background)

notion image
notion image

(3)设置背景颜色示例(backgroundTint)

notion image

2.4 EditText

(1)属性

notion image

(2)示例

(3)应用

notion image

2.5 ImageView

(1)属性

notion image

(2)属性scaleType的缩放类型

notion image

(3)示例

2.6 progressBar

(1)属性

notion image

(2)示例

2.7 Notification

(1)属性

notion image
notion image
notion image

(2)示例

2.8 Toolbar

(1)属性

notion image

(2)示例

2.9 AlertDialog

(1)实现方式

notion image

(2)示例

2.10 PopupWindow

(1)常用方法

notion image

(2)语句注释说明

三、如何让新建的布局xml文件转变为View对象

四、ListView

4.1 含义

  • 容器(列表),装载显示数据(item)
  • item中的具体数据由适配器(视图与数据之间的桥梁或者中介,将数据映射到要展示的View中;Adapter)提供

4.2 示意图

notion image

4.3 提供的 xml 属性

notion image

五、Adapter

notion image
  • Adapter 接口派生了 ListAdapter 和 SpinnerAdapter 两个子接口 其中 ListAdapter 为 AbsAdapter 提供列表项,SpinnerAdapter 为 AbsSpinner 提供列表项
  • ArrayAdapter 、SimpleAdapter 都是 Android API 给我们提供好的适配器,直接使用即可,不过模式都已经写死了。
  • ArrayAdapter:简单、易用的 Adapter,用于将数组数据作为数据源绑定到列表项中。支持泛型操作 SimpleAdapter:相比 ArrayAdapter 来说,功能比较强大,可以将数据源的数据一一的绑定到 item 中的 view 中。
  • CursorAdapter:用于绑定游标(直接从数据库取出数据)作为列表项的数据源,和数据库有关系,不常用。
  • BaseAdapter:这个是我们在实际开发中经常用到的,我们需要继承 BaseAdapter 来自定义我们自己的适配器。

六、Log工具打印日志

notion image

七、项目目录功能

notion image
notion image

八、尺寸与转换

notion image

九、文本颜色

notion image

十、视图的对齐方式

notion image
 
LinuxC语言(1)
Loading...