当前位置:网站首页>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。
边栏推荐
- The use of list and Its Simulation Implementation
- From pornographic live broadcast to live broadcast E-commerce
- 90后,辞职创业,说要卷死云数据库
- uniCloud
- 2021 summary and 2022 outlook
- Force buckle 1002 Find common characters
- [untitled]
- The opacity value becomes 1%
- Wallhaven wallpaper desktop version
- [C #] the solution of WinForm operation zoom (blur)
猜你喜欢
JSON format query of MySQL
[untitled]
[STM32] actual combat 3.1 - drive 42 stepper motors with STM32 and tb6600 drivers (I)
关于测试人生的一站式发展建议
[untitled]
Using ENSP to do MPLS pseudo wire test
Still cannot find RPC dispatcher table failed to connect in virtual KD
Vscode 尝试在目标目录创建文件时发生一个错误:拒绝访问【已解决】
The database synchronization tool dbsync adds support for mongodb and es
Socket socket programming
随机推荐
Which securities company is the best and safest to open an account for the subscription of new shares
The fifth training assignment
Network foundation (1)
2021-04-08
基于Retrofit框架的金山API翻译功能案例
The post-90s resigned and started a business, saying they would kill cloud database
V-for img SRC rendering fails
Simple and easy to modify spring frame components
Still cannot find RPC dispatcher table failed to connect in virtual KD
A simple example of delegate usage
对比学习之 Unsupervised Learning of Visual Features by Contrasting Cluster Assignments
2021-04-23
Ping tool ICMP message learning
【C#】WinForm运行缩放(变糊)的解决方法
Unity websocket client
Arduino board description
Interprocess communication (IPC)
How to remove addition and subtraction from inputnumber input box
基于DE2 115开发板驱动HC_SR04超声波测距模块【附源码】
POJ1821 Fence 题解报告