-
Notifications
You must be signed in to change notification settings - Fork 780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2019-08-28:谈一谈获取View宽高的几种方法? #131
Comments
view.post一个就行了 一把梭 |
1.OnGlobalLayoutListener获取 |
使用MessageQueue.addIdleHandler()也可以获取,而且可以防止多次调用。 |
使用View.post()方法 |
先说下问题的考点: 首先,在 view 测量过后就可以获得 view 的测量宽高,另外系统可能需要多次 measure 才能确定最终的测量宽高。 能获取真实 view 宽高的方法:
|
1 通过 looper 队列
2 当视图树的布局发生改变时
3 当视图树的进行绘制时
4 view 布局改变时
|
通过view.post Runnable方法里面通过view.getHeight |
看了上方的回答,发现“答不对题”;题目是:获取View宽高的几种方法;回答应该是获取方法,而上文回答的全是”获取时机“
|
No description provided.
The text was updated successfully, but these errors were encountered: