Reputation: 2535
Title of question says it all, I am trying to make a view like shown, here center part should be exactly half size of the screen and should be present at center of screen.
I am using layout_weight and weightsum and avoid padding left and right:
<LinearLayout
android:id="@+id/OuterlinLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="4" >
<LinearLayout
android:id="@+id/containerLayout1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="horizontal" />
<LinearLayout
android:id="@+id/GlobalLayout"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_weight="2"
android:orientation="vertical" >contens of main view</LinearLayout>
<LinearLayout
android:id="@+id/containerLayout2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:orientation="horizontal" >
But it is not showing what i wanted...what is the mistake that i am making?
Upvotes: 1
Views: 1589
Reputation: 17850
Your OuterlinLayout LinearLayout
should have android:orientation="horizontal"
instead of vertical and all its children should have android:layout_width="0dp"
Upvotes: 5