madcoderz
madcoderz

Reputation: 4431

how to separate icons from eachother android

i have a navigation bar on the bottom of the screen. I have a set of 3 buttons in this navbar, the buttons have an icon as background button there's no space between eachother. I've been searching in Google how to separate them from eachother but i haven't succeded. The questiion is: how can i separate them from eachother? here's is my xml code:

Main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />

    <LinearLayout 
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:background="#5E767E"
    android:gravity="center"
    >

        <Button 
        android:layout_height="wrap_content" 
        android:id="@+id/back" 
        android:layout_width="wrap_content"
        android:background="@drawable/button"
        />

        <Button 
        android:layout_height="wrap_content" 
        android:id="@+id/home" 
        android:layout_width="wrap_content"
        android:background="@drawable/button"
        />

        <Button 
        android:layout_height="wrap_content" 
        android:id="@+id/next" 
        android:layout_width="wrap_content" 
        android:background="@drawable/button"
        />

    </LinearLayout>


</RelativeLayout>

Upvotes: 0

Views: 3472

Answers (2)

Stephan
Stephan

Reputation: 1868

Have you tried putting an empty View in between?

<Button 
        android:layout_height="wrap_content" 
        android:id="@+id/back" 
        android:layout_width="wrap_content"
        android:background="@drawable/button"
        />
<View android:layout_width="2dip" android:layout_height="1dip"/>
        <Button 
        android:layout_height="wrap_content" 
        android:id="@+id/home" 
        android:layout_width="wrap_content"
        android:background="@drawable/button"
        />
<View android:layout_width="2dip" android:layout_height="1dip"/>
        <Button 
        android:layout_height="wrap_content" 
        android:id="@+id/next" 
        android:layout_width="wrap_content" 
        android:background="@drawable/button"
        />

Play with the width and height of it to suit your needs. It usually does the trick for me.

Upvotes: 0

Cristian
Cristian

Reputation: 200080

Apply margin or padding, for instance:

    <Button 
    android:layout_height="wrap_content" 
    android:id="@+id/back" 
    android:layout_width="wrap_content"
    android:background="@drawable/button"
    android:margin="10dip"
    />

Or:

    <Button 
    android:layout_height="wrap_content" 
    android:id="@+id/back" 
    android:layout_width="wrap_content"
    android:background="@drawable/button"
    android:marginLeft="10dip"
    android:marginRight="10dip"
    />

This could be useful for you: Difference between a View's Padding and Margin

Upvotes: 2

Related Questions