I have a LinearLayout
and in LinearLayout I have a ImageView
and a TextView
. I want to set %50 width each of them. I used weightSum
and layout_weight
for this purpose but my it is not working. How can I set 50% width to each Views
As you can see below weight = 10 and TextView
and ImageView
has 5 for weight
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/my_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:background="#3e4231"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.hakkikonu.countriesultimate.CountryDetails" >
<TextView
android:id="@+id/tv_show_extra"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:background="#ff4444"
android:text="Country Name"
android:textColor="#FFFFFF"
android:textSize="24sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="10" >
<ImageView
android:id="@+id/iv_bayrak_goster"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="5"
android:adjustViewBounds="true"
android:baselineAlignBottom="false"
android:src="@drawable/default_flag" />
<TextView
android:id="@+id/tv_capital"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:background="#ff4444"
android:text="Capital"
android:textColor="#FFFFFF"
android:textSize="16sp"
android:layout_weight="5"/>
</LinearLayout>