Android setContentView operation

android, android-activity, view

Solution

does the view get drawn to screen as soon as setContentView() is called

No.

or does it allow the onCreate() function to build/populate the information in the view objects, and wait to actually draw it after onCreate() completes?

Yes. The `View` objects are created immediately as part of `setContentView()`. However, all drawing operations (from `onCreate()` or anywhere else) really result in messages being put on a message queue that the main application thread works through.

Problem

I've read that it's important to call setContentView() early in an activity since it builds the view objects that may be manipulated by subsequent code in onCreate(). In terms of lifecycle, does the view get drawn to screen as soon as setContentView() is called, or does it allow the onCreate() function to build/populate the information in the view objects, and wait to actually draw it after onCreate() completes? Thanks!

Original source