我正在尝试创建具有四个按钮的布局。
我设法显示了四个图像按钮,但我无法显示分隔线。在下图中,您可以看到我想要设计的内容:
答案 0 :(得分:2)
使用相对布局并首先添加View对象以将它们分开(参见下文)。你必须添加你想要的任何其他参数......
<RelativeLayout
android:layout_width = "match_parent"
android:layout_height = "match_parent">
<View
android:id = "@+id/vertical_divider"
android:layout_centerHorizontal = "true"
android:layout_width = "1dip"
android:layout_height = "match_parent">
</View>
<View
android:id = "@+id/horizontal_divider"
android:layout_centerVertical = "true"
android:layout_width = "match_parent"
android:layout_height = "1dip">
</View>
<ImageButton
android:layout_alignParentTop = "true"
android:layout_alignParentLeft = "true"
android:layout_toLeftOf = "@id/vertical_divider"
android:layout_above = "@id/horizontal_divider"
android:layout_width = "match_parent"
android:layout_height = "match_parent">
</ImageButton>
<ImageButton
android:layout_alignParentTop = "true"
android:layout_alignParentRight = "true"
android:layout_toRightOf = "@id/vertical_divider"
android:layout_above = "@id/horizontal_divider"
android:layout_width = "match_parent"
android:layout_height = "match_parent">
</ImageButton>
<ImageButton
android:layout_alignParentBottom = "true"
android:layout_alignParentLeft = "true"
android:layout_toLeftOf = "@id/vertical_divider"
android:layout_below = "@id/horizontal_divider"
android:layout_width = "match_parent"
android:layout_height = "match_parent">
</ImageButton>
<ImageButton
android:layout_alignParentBottom = "true"
android:layout_alignParentRight = "true"
android:layout_toRightOf = "@id/vertical_divider"
android:layout_below = "@id/horizontal_divider"
android:layout_width = "match_parent"
android:layout_height = "match_parent">
</ImageButton>
</RelativeLayout>
答案 1 :(得分:0)
在layout_marginBottom="1dip"
。
layout_marginRight="1dip"
和Imageviews