Container like div, span etc
In XML, the equivalent of a Div
, is a ViewGroup
.
Example: LinearLayout
, RelativeLayout
etc.
ViewGroups can contain Views and Controls like: TextView
, Button
and EditView
.
I created an example of what I think you're asking:
I used a LinearLayout
to hold our Views and Controls.
Then I used android:gravity="center_horizontal"
, on our LinearLayout
, to center the children.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center_horizontal" tools:context=".MainActivity" > <TextView android:layout_width="200dp" android:gravity="center_horizontal" android:layout_height="wrap_content" android:text="@string/hello_world" /> <Button android:layout_width="200dp" android:layout_height="wrap_content" android:text="@string/hello_world" /> <EditView android:layout_width="200dp" android:layout_height="wrap_content" android:text="@string/hello_world" /></LinearLayout>
Here's what it looks like: