当前位置:网站首页>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。
边栏推荐
- Web端自动化测试失败的原因
- Rolling puddle Uni_ App (VIII)
- TDengine 社区问题双周精选 | 第二期
- Avoid mutating a prop directly since the value will be overwritten whenever the parent component
- The post-90s resigned and started a business, saying they would kill cloud database
- Still cannot find RPC dispatcher table failed to connect in virtual KD
- Using ENSP to do MPLS pseudo wire test
- Table replication in PostgreSQL
- Vscode 尝试在目标目录创建文件时发生一个错误:拒绝访问【已解决】
- A case of compiling QT file qmake compiling script
猜你喜欢

2021-05-21

面试被问到了解哪些开发模型?看这一篇就够了
![[untitled]](/img/8e/e968d4629004bb0c3ee70328b6777b.jpg)
[untitled]

测试开发基础,教你做一个完整功能的Web平台之环境准备

從色情直播到直播電商

VR development optimization

Using ENSP to do MPLS pseudo wire test

"Dream Cup" 2017 Jiangsu information and future primary school summer camp it expert PK program design questions

Unity script generates configurable files and loads

oracle常见锁表处理方式
随机推荐
毕业季|与青春作伴,一起向未来!
[untitled]
Ffmpeg record a video command from RTSP
Avoid mutating a prop directly since the value will be overwritten whenever the parent component
Case study of Jinshan API translation function based on retrofit framework
Debezium同步之Debezium架构详解
How to play video on unityui
对比学习之 Unsupervised Learning of Visual Features by Contrasting Cluster Assignments
基于Retrofit框架的金山API翻译功能案例
Network foundation (1)
How to get hardware information in unity
Long list performance optimization scheme memo
Poj1821 fence problem solving Report
Unity determines whether the mouse clicks on the UI
從色情直播到直播電商
软件设计之——“高内聚低耦合”
Static semantic check of clang tidy in cicd
Input type= "password" how to solve the problem of password automatically brought in
Wallhaven壁纸桌面版
测试优惠券要怎么写测试用例?