当前位置:网站首页>Android 面试知识点
Android 面试知识点
2022-07-07 09:10:00 【InfoQ】
Requestlayout,OnLayout,OnDraw,DrawChild区别与联系
- requestLayout()方法 :会导致调用measure()过程 和 layout()过程 。说明:只是对View树重新布局layout过程包括measure()和layout()过程,不会调用draw()过程,但不会重新绘制任何视图包括该调用者本身。
- onLayout()方法(如果该View是ViewGroup对象,需要实现该方法,对每个子视图进行布局)
- onDraw()方法绘制视图本身 (每个View都需要重载该方法,ViewGroup不需要实现该方法)
- drawChild()去重新回调每个子视图的draw()方法。
Android为每个应用程序分配的内存大小是多少?
Android View刷新机制
- mView.draw()开始绘制,draw()方法实现的功能如下:绘制该View的背景为显示渐变框做一些准备操作。
- 调用onDraw()方法绘制视图本身 (每个View都需要重载该方法,ViewGroup不需要实现该方法)
- 调用dispatchDraw ()方法绘制子视图(如果该View类型不为ViewGroup,即不包含子视图,不需要重载该方法)值得说明的是,ViewGroup类已经为我们重写了dispatchDraw ()的功能实现,应用程序一般不需要重写该方法,但可以重载父类函数实现具体的功能。
LinearLayout对比RelativeLayout
- RelativeLayout会让子View调用2次onMeasure,LinearLayout 在有weight时,也会调用子View2次onMeasure
- RelativeLayout的子View如果高度和RelativeLayout不同,则会引发效率问题,当子View很复杂时,这个问题会更加严重。如果可以,尽量使用padding代替margin。在不影响层级深度的情况下,使用LinearLayout和FrameLayout而不是RelativeLayout。
边栏推荐
- 关于测试人生的一站式发展建议
- Simple and easy to modify spring frame components
- The seventh training assignment
- Avoid mutating a prop directly since the value will be overwritten whenever the parent component
- Array object sorting
- 测试优惠券要怎么写测试用例?
- VIM命令模式与输入模式切换
- 基于Retrofit框架的金山API翻译功能案例
- [untitled]
- The opacity value becomes 1%
猜你喜欢

Verilog 实现数码管显视驱动【附源码】

Opencv installation and environment configuration - vs2017

从色情直播到直播电商

Activity生命周期

关于在云服务器上(这里用腾讯云)安装mysql8.0并使本地可以远程连接的方法

Using ENSP to do MPLS pseudo wire test

基于华为云IOT设计智能称重系统(STM32)

科普达人丨一文弄懂什么是云计算?

Seata 1.3.0 four modes to solve distributed transactions (at, TCC, Saga, XA)

学习笔记|数据小白使用DataEase制作数据大屏
随机推荐
基于Retrofit框架的金山API翻译功能案例
The database synchronization tool dbsync adds support for mongodb and es
electron添加SQLite数据库
Shardingsphere sub database and table examples (logical table, real table, binding table, broadcast table, single table)
对比学习之 Unsupervised Learning of Visual Features by Contrasting Cluster Assignments
vim 的各种用法,很实用哦,都是本人是在工作中学习和总结的
Eth trunk link switching delay is too high
Socket socket programming
PR Lecture Notes
Kitex retry mechanism
[untitled]
A simple example of delegate usage
從色情直播到直播電商
Kitex 重试机制
Laya common script commands
90后,辞职创业,说要卷死云数据库
Bookmarking - common website navigation for programmers
基于华为云IOT设计智能称重系统(STM32)
Avoid mutating a prop directly since the value will be overwritten whenever the parent component
软件设计之——“高内聚低耦合”