对于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 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和getHeight获取的是View当前实际显示的大小,而getMeasured相关的函数则获取的是View在父类中计算的需要占用的大小。 |
|