對于View的兩個大小的API,以前有很多迷惑,不知道具體其含義,今天在看google官方文檔的時候看到如下描述, 終于恍然大悟?,F(xiàn)記錄如下: 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在父類中計算的需要占用的大小。 |
|