Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

layout_weight=1.0 doesn't have effect

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

    <TextView
        android:id="@+id/tv_label_client_host"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:text="@string/label_host" />
    <EditText
        android:id="@+id/et_client_host"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:ems="10" 
        android:inputType="text"
        android:layout_weight="1.0"
        android:lines="1" />
</LinearLayout>

I expect EditText to fill the whole space remaining by horizontal, but TextView and EditText get 1/2 of available space. This LinearLayout is placed inside of another vertical LinearLayout.

like image 461
Alex F Avatar asked May 16 '26 03:05

Alex F


1 Answers

remove the

   android:ems="10"

for all the elements, I tested here and it works.

like image 196
lucasjmatias Avatar answered May 18 '26 17:05

lucasjmatias



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!