Proportional width of elements in LinearLayout

I have horizontal LinearLayout, and it has elements EditTextand Spinner. What attributes do I need to set to get a proportional width: do I want to EditTextaccept 3/5 and Spinner- 2/5 of the total available width?

My code is as follows:

<LinearLayout 
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent" 
    android:id="@+id/LinearLayout01">

    <EditText 
        android:layout_height="wrap_content" 
        android:id="@+id/EditText01" 
        android:singleLine="true">
    </EditText>

    <Spinner 
        android:layout_height="wrap_content" 
        android:id="@+id/Spinner01" 
        android:layout_width="wrap_content">
    </Spinner>

</LinearLayout>

I tried the setup android:layout_weight, but for some reason it does not look “stable” to me - when EditTextit has no text - everything looks good, but as soon as I start to enter text into it - it starts to expand and Spinnershrink accordingly ...

+5
source share
2 answers

, android:layout_width="0px", , , android:layout_weight (3 2).

+13

layout_width 0dip, layout_weight. .

+1

All Articles