As we see, you have assigned the weight to your line layout.
If you have assigned the weight of your parent layout , you just need to set the appropriate height either using 0dp . In your case android:layout_width="0dp"
but if you have a child layout of this weighted layout, you must specify the layouts property as fill_parent ie: button android:layout_height="fill_parent"
So, if you do not want to change the parent layout and want to work with existing code, you can try to execute the code below.
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:baselineAligned="false" android:orientation="horizontal" > <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="5" android:orientation="vertical" > <TextView android:id="@+id/tv_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" /> <TextView android:id="@+id/tv_time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="2" > <ImageView android:id="@+id/iv_image" android:layout_width="fill_parent" android:layout_height="40dp" android:background="@drawable/icon" android:contentDescription="@string/app_name" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="2" > <Button android:id="@+id/btn_delete" android:layout_width="fill_parent" android:layout_height="40dp" android:background="@drawable/icon" android:focusable="false" /> </LinearLayout> </LinearLayout>
source share