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.
Asked
Active
Viewed 211 times
2 Answers
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>

Santosh Kumar Gupta
- 74
- 2