what is the best android layout
I used both RelativeLayout and Linearlayout to achieve this.(in the image)
Using relative layout, I positioned the buttons with fixed width, and with
marginLeft and marginRight. The problem is, if the device has bigger
screen, the left, right margins don't expand much, also the button width
is fixed.
<!-- Row1 -->
<Button1
alignParentTop = "true"
marginLeft = "5dip"
marginRight="5dip"
width="80dip"/>
<button2
alignParentTop ="true"
center="@id/Button1"
marginLeft = "5dip"
marginRight="5dip"
width="80dip" />
<button2
alignParentRight="true"
marginLeft = "5dip"
marginRight="5dip"
width="80dip"/>
<!-- Row2 -->
<Button3
below="button1"
marginLeft = "5dip"
marginRight="5dip"
width="80dip"/>
<Button4
below="button2"
marginLeft = "5dip"
marginRight="5dip"
width="80dip"/>
</RelativeLayout>
Using RelativeLayout parent, created 2 horizontal linearlayout with
buttons. Now buttons have 0dip width with weight 1. However, I cannot
create the 2nd row.
<RelativeLayout>
<linearLayout orientation="horizontal">
<!-- Row1 -->
<Button1
width="0dip"
weight="1"/>
<button2
width="0dip"
weight="1"/>
<button2
width="0dip"
weight="1"/>
<!--Row2-->
</RelativeLayout>
Couldn't using this approach
No comments:
Post a Comment