Activity.addContentView(View) == ViewGroup.addContentView(View)? Activity.addContentView(View) == ViewGroup.addContentView(View)? android android

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:

enter image description here

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.

enter image description here

After adding a TextView via addContentView() it looks like this. You can see that the base FrameLayout got a new child.