一、View
1.1、View 概述
视图 (View) 是一个容器,专门负责布局。表现为显示在屏幕上的各种视图,如 TextView、LinearLayout 等。
1.2、View 分类
View 主要分为两类,具体如下表格所示:
类别 | 示例 | 特点 |
---|---|---|
单一视图 | 即一个 View,如 TextView、EditText | 不包含子View |
视图组 | 即多个 View 组成的 ViewGroup,如 RelativeLayout | 包含子View |
1.3、View 类简介
-
View 类是 Android 中各种组件的基类;
-
View 的构造函数有四个,具体如下所示:
public View(Context context) { } public View(Context context, @Nullable AttributeSet attrs) { this(context, attrs, 0); } public View(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { this(context, attrs, defStyleAttr, 0); } public View(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { }
-
源码中 View 的构造函数
<