maidi
maidi

Reputation: 3459

LinearLayouts with same widths in other LinearLayout

I have a horizontal LinearLayout and inside of it 3 vertical LinearLayouts with TextsViews in it. I want the 3 LinearLayouts to have equal width. I already tried weight and sumweight but as you can see the columns haven't equal width:

Grey: outer horizontal LinearLayout

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:background="#455A63"
        android:gravity="center"
        android:padding="10dp">

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:weightSum="1">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginLeft="8dp"
                android:layout_marginRight="8dp"
                android:textAlignment="center"/>

            <TextView/> <!--same configurations as above-->

        </LinearLayout>

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:weightSum="1">

            <TextView />

            <TextView/>
        </LinearLayout>

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:weightSum="1">

            <TextView />

            <TextView/>
        </LinearLayout>

    </LinearLayout>

Upvotes: 0

Views: 1408

Answers (1)

Mihir
Mihir

Reputation: 56

For the three inner Linear Layouts, you need to specify android:layout_weight="1" and the android:layout_width="0dp" No need to have weight_sum

Upvotes: 3

Related Questions