正文
之后就是调用
ViewRootImpl.setLayoutParams
来设置新的 params 。
ViewRootImpl
setLayoutParams(WindowManager.LayoutParams attrs, boolean newView)
void setLayoutParams(WindowManager.LayoutParams attrs, boolean newView) {
synchronized (this) {
...
applyKeepScreenOnFlag(mWindowAttributes);
// 传入的 newView 是 false ,不执行这些代码
if (newView) {
mSoftInputMode = attrs.softInputMode;
requestLayout();
}
// Don't lose the mode we last auto-computed.
if ((attrs.softInputMode & WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST)
== WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED) {
mWindowAttributes.softInputMode = (mWindowAttributes.softInputMode
& ~WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST)
| (oldSoftInputMode & WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST);
}
mWindowAttributesChanged = true;
// 使 view 重走三大流程
scheduleTraversals();
}
}
在
setLayoutParams
中,调用了
scheduleTraversals()
方法。
在之前讲 View 工作原理的时候,我们都看过
scheduleTraversals()
最后会调用
performTraversals()
来开始 View 的测量、布局和绘制。所以在这,也就触发了 View 重新去调整自己。