Just use RelativeLayout or FrameLayout . The last child view will override everything else.
Android supports a template that Cocoa Touch SDK does not support: Manage layouts.
Layout for iPhone means position absolutely (except for some strech factors). The layout in android means that the children will be placed relative to each other.
Example (second EditText fully covers the first):
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/root_view"> <EditText android:layout_width="fill_parent" android:id="@+id/editText1" android:layout_height="fill_parent"> </EditText> <EditText android:layout_width="fill_parent" android:id="@+id/editText2" android:layout_height="fill_parent"> <requestFocus></requestFocus> </EditText> </FrameLayout>
FrameLayout is some kind of view stack. Made for special occasions.
RelativeLayout quite powerful. You can define rules such as "View A" to align the parent layout at the bottom, "View B" should align from bottom to top, etc.
Comment Based Update
Usually you set the content with setContentView(R.layout.your_layout) to onCreate (it will inflate the layout for you). You can do it manually and call setContentView(inflatedView) , there is no difference.
The view itself can be a single view (for example, TextView ) or a complex layout hierarchy (nested layouts, since all layouts are the views themselves).
After calling setContentView your activity knows what its contents look like, and you can use (FrameLayout) findViewById(R.id.root_view) to get any view in this hierarchy (General template (ClassOfTheViewWithThisId) findViewById(R.id.declared_id_of_view) ).
Knickedi Sep 22 '11 at 17:55 2011-09-22 17:55
source share