Android(安卓)用户界面(User Interface)
16lz
2021-01-26
View 基类:
视图对象在屏幕特定矩形区域处理自己的尺寸,布局,绘图,焦点切换,滚动,按键/手势交互.也
接收用户交互事件.
View 是 Widget基类,为之提供服务.
ViewGroup 是 Layout 基类,为之提供服务.
视图体系:
布局:
声明式布局 main.xml
Widgets:
UI组件
UI 事件:
1.定义一个事件监听器,并使用视图注册
2.重写视图回调方法
Menus:
MENU key
菜单键
定义
onCreateOptionsMenu()
onCreateContextMenu()
回调方法声明菜单项.不需要注册事件监听器在菜单中.
声明式菜单项.
Adapters:
适配器
Styles and Themes:
样式:View
主题:Activity或应用
声明式布局:
使用XML文件来描述布局,避免硬编码.提高布局的灵活性.同时表现与行为分离.
创建菜单:
可选菜单:包括图标菜单和扩展菜单.图标菜单最多支持6个菜单项.不支持单选,多选框.
上下文菜单:
子菜单:作文可选菜单和上下文菜单的子菜单,但不能再嵌套子菜单.
在XML中定义菜单
快捷键
Creating Dialogs:
AlertDialog
ProgressDialog
DatePickerDialog
TimePickerDialog
处理 UI Events:
onClick()
From View.OnClickListener.
This is called when the user either touches the item (when in touch mode), or focuses upon the item with the navigation-keys or trackball and presses the suitable "enter" key or presses down on the trackball.
onLongClick()
From View.OnLongClickListener.
This is called when the user either touches and holds the item (when in touch mode), or focuses upon the item with the navigation-keys or trackball and presses and holds the suitable "enter" key or presses and holds down on the trackball (for one second).
onFocusChange()
From View.OnFocusChangeListener.
This is called when the user navigates onto or away from the item, using the navigation-keys or trackball.
onKey()
From View.OnKeyListener.
This is called when the user is focused on the item and presses or releases a key on the device.
onTouch()
From View.OnTouchListener.
This is called when the user performs an action qualified as a touch event, including a press, a release, or any movement gesture on the screen (within the bounds of the item).
onCreateContextMenu()
From View.OnCreateContextMenuListener.
This is called when a Context Menu is being built (as the result of a sustained "long click"). See the discussion on context menus in Creating Menus for more information.
事件处理器:
onKeyDown(int, KeyEvent) - 按键.
onKeyUp(int, KeyEvent) - 按键.
onTrackballEvent(MotionEvent) - Called when a trackball motion event occurs.
onTouchEvent(MotionEvent) - 触摸屏幕
onFocusChanged(boolean, int, Rect) - 获取和失去焦点
用户通知:
Toast Notification: 弹出一个窗口
Status Bar Notification: 状态条
Dialog Notification: 对话框
应用样式和主题:
styles.xml
自定义UI组件:
AdapterView 绑定数据
常用布局对象:
FrameLayout: 帧布局,所有子对象都定位在左上角,并且重叠放置.
LinearLayout: 线性布局,所有子对象从左到右依次排列或从上到下依次排列.不换行/列.
TableLayout: 表格布局,简单表格行列式布局.
RelativeLayout: 相对布局,相对元素布局.
视图渲染:
视图渲染是从视图树根结点开始.分2个过程.第一个过程计算大小measure,第二个过程确定布局layout.
视图渲染从根结点开始广度优先draw().
视图对象在屏幕特定矩形区域处理自己的尺寸,布局,绘图,焦点切换,滚动,按键/手势交互.也
接收用户交互事件.
View 是 Widget基类,为之提供服务.
ViewGroup 是 Layout 基类,为之提供服务.
视图体系:
ViewGroup |ViewGroup | |View ViewGroup | View
布局:
声明式布局 main.xml
Widgets:
UI组件
UI 事件:
1.定义一个事件监听器,并使用视图注册
2.重写视图回调方法
Menus:
MENU key
菜单键
定义
onCreateOptionsMenu()
onCreateContextMenu()
回调方法声明菜单项.不需要注册事件监听器在菜单中.
声明式菜单项.
Adapters:
适配器
Styles and Themes:
样式:View
主题:Activity或应用
声明式布局:
使用XML文件来描述布局,避免硬编码.提高布局的灵活性.同时表现与行为分离.
创建菜单:
可选菜单:包括图标菜单和扩展菜单.图标菜单最多支持6个菜单项.不支持单选,多选框.
上下文菜单:
子菜单:作文可选菜单和上下文菜单的子菜单,但不能再嵌套子菜单.
在XML中定义菜单
快捷键
Creating Dialogs:
AlertDialog
ProgressDialog
DatePickerDialog
TimePickerDialog
处理 UI Events:
onClick()
From View.OnClickListener.
This is called when the user either touches the item (when in touch mode), or focuses upon the item with the navigation-keys or trackball and presses the suitable "enter" key or presses down on the trackball.
onLongClick()
From View.OnLongClickListener.
This is called when the user either touches and holds the item (when in touch mode), or focuses upon the item with the navigation-keys or trackball and presses and holds the suitable "enter" key or presses and holds down on the trackball (for one second).
onFocusChange()
From View.OnFocusChangeListener.
This is called when the user navigates onto or away from the item, using the navigation-keys or trackball.
onKey()
From View.OnKeyListener.
This is called when the user is focused on the item and presses or releases a key on the device.
onTouch()
From View.OnTouchListener.
This is called when the user performs an action qualified as a touch event, including a press, a release, or any movement gesture on the screen (within the bounds of the item).
onCreateContextMenu()
From View.OnCreateContextMenuListener.
This is called when a Context Menu is being built (as the result of a sustained "long click"). See the discussion on context menus in Creating Menus for more information.
事件处理器:
onKeyDown(int, KeyEvent) - 按键.
onKeyUp(int, KeyEvent) - 按键.
onTrackballEvent(MotionEvent) - Called when a trackball motion event occurs.
onTouchEvent(MotionEvent) - 触摸屏幕
onFocusChanged(boolean, int, Rect) - 获取和失去焦点
用户通知:
Toast Notification: 弹出一个窗口
Status Bar Notification: 状态条
Dialog Notification: 对话框
应用样式和主题:
styles.xml
自定义UI组件:
AdapterView 绑定数据
常用布局对象:
FrameLayout: 帧布局,所有子对象都定位在左上角,并且重叠放置.
LinearLayout: 线性布局,所有子对象从左到右依次排列或从上到下依次排列.不换行/列.
TableLayout: 表格布局,简单表格行列式布局.
RelativeLayout: 相对布局,相对元素布局.
视图渲染:
视图渲染是从视图树根结点开始.分2个过程.第一个过程计算大小measure,第二个过程确定布局layout.
视图渲染从根结点开始广度优先draw().
更多相关文章
- Android布局方式浅析
- CoderPig’s Android(安卓)Study Note——目录
- Android(安卓)popupwindow弹出对话框
- Android中快速为Recyclerview添加头部
- Android(安卓)FrameLayout布局中的控件设置居中动态设置
- Android(安卓)studio登录界面
- MVVM + dataBinding
- android圆形旋转菜单,教你分分钟搞定它,CircleMenu
- android 在当前的布局上加载xml填充内部