We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
在ActivityThread.handleResumeActivity 里触发的。
ActivityThread.handleResumeActivity
public void handleResumeActivity(IBinder token, boolean finalStateRequest, boolean isForward, String reason) { // ... if (r.window == null && !a.mFinished && willBeVisible) { r.window = r.activity.getWindow(); View decor = r.window.getDecorView(); decor.setVisibility(View.INVISIBLE); ViewManager wm = a.getWindowManager(); WindowManager.LayoutParams l = r.window.getAttributes(); a.mDecor = decor; // ... if (a.mVisibleFromClient) { if (!a.mWindowAdded) { a.mWindowAdded = true; wm.addView(decor, l); } else { // ... } } // If the window has already been added, but during resume // we started another activity, then don't yet make the // window visible. } else if (!willBeVisible) { if (localLOGV) Slog.v(TAG, "Launch " + r + " mStartedActivity set"); r.hideForNow = true; } // ... }
ActivityThread.handleResumeActivity 里会调用 wm.addView 来添加 DecorView,wm 是 WindowManagerImpl
wm.addView
DecorView
wm
WindowManagerImpl
// WindowManagerImpl public void addView(@NonNull View view, @NonNull ViewGroup.LayoutParams params) { applyDefaultToken(params); mGlobal.addView(view, params, mContext.getDisplay(), mParentWindow); } // WindowManagerGlobal public void addView(View view, ViewGroup.LayoutParams params, Display display, Window parentWindow) { // 这里的 view 就是 DecorView // ... ViewRootImpl root; View panelParentView = null; synchronized (mLock) { // ... root = new ViewRootImpl(view.getContext(), display); view.setLayoutParams(wparams); mViews.add(view); mRoots.add(root); mParams.add(wparams); // do this last because it fires off messages to start doing things try { root.setView(view, wparams, panelParentView); } catch (RuntimeException e) { } } } // ViewRootImpl.setView public void setView(View view, WindowManager.LayoutParams attrs, View panelParentView) { requestLayout(); }
最终通过 WindowManagerImpl.addView -> WindowManagerGlobal.addView -> ViewRootImpl.setView -> ViewRootImpl.requestLayout 就触发了第一次 View 的绘制。
WindowManagerImpl.addView
WindowManagerGlobal.addView
ViewRootImpl.setView
ViewRootImpl.requestLayout
View
The text was updated successfully, but these errors were encountered:
No branches or pull requests
在
ActivityThread.handleResumeActivity
里触发的。ActivityThread.handleResumeActivity
里会调用wm.addView
来添加DecorView
,wm
是WindowManagerImpl
最终通过
WindowManagerImpl.addView
->WindowManagerGlobal.addView
->ViewRootImpl.setView
->ViewRootImpl.requestLayout
就触发了第一次View
的绘制。The text was updated successfully, but these errors were encountered: