I'm having some issues getting two children of a LinearLayout
to have the same width. This is what I am getting:
And here is my layout xml for the grey box:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2"
android:background="@color/medium_grey"
>
<ImageView
android:id="@+id/profile_photo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:src="@drawable/placeholder_profile_photo"
android:scaleType="fitCenter"
android:contentDescription="@string/blank"
android:layout_weight="1"
/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:background="@color/alert"
>
<TextView
android:id="@+id/profile_rate_header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Rate User"
/>
<LinearLayout
android:id="@+id/profile_action_rate_user"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1"
android:gravity="center"
>
<ImageView
android:id="@+id/profile_action_rate_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/user_rate_up"
/>
<ImageView
android:id="@+id/profile_action_rate_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/user_rate_down"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
I was assuming that setting the layout_weight
of the children of the root LinearLayout
along with a weightSum
and width of 0dp
would produce the desired effect (image being the same size as the pink 'rate user' section) however this isn't the case.
What am I missing?
Edit:
This is what I want it to look like
The photo and the pink linear layout should be equal widths.