开发者

Dynamically expanding widgets on Android UI

I'm trying to create a simple Android UI that consists of a EditText and Button widget. Howev开发者_开发知识库er 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


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"
/>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜