Activity.addContentView(View) == ViewGroup.addContentView(View)?
The base layout of every activity is a FrameLayout
. This means the layout you usually set via setContentView()
is a child of this layout. addContentView()
adds just another child, therefore it behaves like a FrameLayout
(which means it adds new UI elements above existing ones).
You can check this by using a tool called hierachyviewer
from your ANDROID_SDK\tools
folder. Here are two screenshots:
This is the layout before calling addContentView()
, my activity consists of the default FrameLayout, holding a LinearLayout with a Button (my layout here). This is reflected in the bottom row here, the other elements above are the title/statusbar.
After adding a TextView via addContentView()
it looks like this. You can see that the base FrameLayout got a new child.