Reputation: 17
we are using eclipse for developing an android app and we simply wants to create 3 buttons that connected to each other. this is the MyActivity .xml ,this look like this, but we want to do button need button without space.
<Button
android:id="@+id/button1
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="0dp"
android:layout_marginLeft="0dp"
android:text="Button" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button1"
android:layout_alignBottom="@+id/button1"
android:layout_alignParentLeft="true"
android:layout_marginLeft="0dp"
android:text="Button" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="Button" />
Here is the Image
.
Upvotes: 1
Views: 365
Reputation: 8645
just use like this android:layout_weight="1"
in every button
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button1" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button2" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button3" />
</LinearLayout>
Upvotes: 0
Reputation:
Use RelativeLayout and center it
then inside the RelativeLayout , create 3 Buttons (button1 , button2 , button3 )
and give them the following attributes :
1- button1
alignParentLeft=true , to TotheLeftOf=button2
2- button2 :
toTHeRightOf=button1 , totheLeftOf=button3
3- button3 :
totheRightOf = button2 , alignparentRight = true .
Hope thats helps
Upvotes: 0
Reputation: 144
Use a LinearLayout with the buttons inside.
<LinearLayout
<Button/>
<Button/>
<Button/>
/>
you can then align the LinearLayout as you wish (center, right, left,...)
Upvotes: 2
Reputation: 2930
you can set margin for that.
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button1"
android:layout_alignBottom="@+id/button1"
android:layout_alignParentLeft="true"
android:layout_marginLeft="-10dp"
android:text="Button" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="Button" />
set minus margin and check your result.
Upvotes: 2