开发者

Help required with layout - not sure which is the best to use

开发者 https://www.devze.com 2023-02-15 02:12 出处:网络
I am new to Android development and having gone through the tutorial resources at developer.android.com, I\'m still not clear which layouts are most useful in different circumstances.

I am new to Android development and having gone through the tutorial resources at developer.android.com, I'm still not clear which layouts are most useful in different circumstances.

To give a specific example, I would like to be able to replicate the UI from the Ebay application i.e a menu bar at the top and bottom of the screen and a panel in the middle. The bottom toolbar has buttons of equal size even when the length of the text differs.

I thought about implementing using a TableLayout with three rows, the top and bottom row containing the toolbars. Then for the bottom row I added a Linear Layout and add开发者_JAVA技巧ed Buttons.

However my buttons are not of equal size and I'm also not sure that this is the best way to layout this UI configuration.

Can somebody provide the XML to achive this.

Thanks


To make two buttons equal in the row you might try:

<LinearLayout android:orientation="vertical">
    <Button android:layout_weight="1" android:layout_width="0dip"/>
    <Button android:layout_weight="1" android:layout_height="0dip"/>
</LinearLayout>

"weight" tells the widget how much of the free space it consumes. two equal weigths = equal size. E.g a weight of 2 and another of 1 means that widget one uses 2/3 of the space and widget two uses 1/3

I am not going to post a layout, the layout you may choose heavily depends on what you are planning to do and how.

Hope that helps

0

精彩评论

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