打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
View 的两对大小 getWidth getHeight getMeasuredWidth getMeasuredHeight
对于View的两个大小的API,以前有很多迷惑,不知道具体其含义,今天在看google官方文档的时候看到如下描述,
终于恍然大悟。现记录如下:

The size of a view is expressed with a width and a height. A view actually possess two pairs of width and height values.

The first pair is known as measured width and measured height. These dimensions define how big a view wants to be within its parent. The measured dimensions can be obtained by calling getMeasuredWidth() andgetMeasuredHeight().

The second pair is simply known as width and height, or sometimes drawing width and drawing height. These dimensions define the actual size of the view on screen, at drawing time and after layout. These values may, but do not have to, be different from the measured width and height. The width and height can be obtained by calling getWidth() and getHeight().

大概意思就是getWidth和getHeight获取的是View当前实际显示的大小,而getMeasured相关的函数则获取的是View在父类中计算的需要占用的大小。

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
onLayout源码 流程 思路详解(ANDROID自定义视图)
Android开发笔记折叠动画效果
Android初级教程
图片进行处理函数
android拼接多张bitmap图片
android 获得屏幕宽度 高度
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服