0

I want to set all my children present inside my Linerlayout to have equal width base on the maximum width required to display the longest child view.

BalaramNayak
  • 1,295
  • 13
  • 16

2 Answers2

0

Make you LinearLayout width as wrap_content and all the child element's width as match_parent.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="small text"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="some long text test" />

    </LinearLayout>
</LinearLayout>
muzamil
  • 196
  • 7
0

Set width of the parent LinearLayout and all the childrens of it to match_parent

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

   <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="small text"/>

   <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="some long text test" />

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