Skip to content
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

"确定View大小(onSizeChanged)" 这一节存在误导 #111

Open
vejei opened this issue Feb 10, 2021 · 0 comments
Open

"确定View大小(onSizeChanged)" 这一节存在误导 #111

vejei opened this issue Feb 10, 2021 · 0 comments

Comments

@vejei
Copy link

vejei commented Feb 10, 2021

onSizeChanged只是在大小被改变时调用,不是用来确定大小的,确定大小就是在onMeasure里面完成的。onMeasure是测量视图的大小的,这个没错,但是它测量大小也就是在确定它的大小,重写时就是根据情况确定(或者叫“测量”)你绘制的内容应该多大。

官方文档

This is called during layout when the size of this view has changed. If you were just added to the view hierarchy, you're called with the old values of 0.

在布局期间,当视图的大小被改变的时候这个会被调用。如果视图是刚刚添加到视图层级中,旧的值会是0。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant