views:

56

answers:

1

Hi,

I'm trying to create a simple Android UI that consists of a EditText and Button widget. However I'm having some problems with setting the layout properties. The UI is supposed to look like this:

▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒

Left is the EditText and right is the Button. The Button (ImageButton) has a widths of approximately 50x50 which I would like to be fixed. The TextBox however should span the entire free space up to the button but I am not able to get this working. I would like to have this work dynamically so I don't have to specify a different layout for different screen sizes or orientation (if this is possible at all).

This is my first Android app so I appreciate any suggestions on how to best build the UI for an application.

Thanks,
b3n

A: 

This should place the elements how you wanted.

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

    android:layout_weight="0.5"
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content"
    android:text="text"/>

    <Button 
    android:id="@+id/b1"
    android:text="test" 
    android:layout_height="50px"
    android:layout_width="50px"
/>

Serhiy
What exactly is the layout weight 0.5 doing?
b3n
I think here is a response for your question: http://stackoverflow.com/questions/3084185/androidlayout-weight-beginners-question
Serhiy