2011-01-11 8 views
0

J'ai une barre de navigation en bas de l'écran. J'ai un ensemble de 3 boutons dans cette barre de navigation, les boutons ont une icône comme bouton d'arrière-plan, il n'y a pas d'espace entre eux. J'ai cherché dans Google comment les séparer les uns des autres mais je n'ai pas réussi. La question est: comment puis-je les séparer les uns des autres? voici mon code xml:comment séparer les icônes les unes des autres android

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> 

Répondre

0

Avez-vous essayé de mettre une vue vide entre?

<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" 
     /> 

Jouez avec la largeur et la hauteur pour répondre à vos besoins. Cela fait habituellement l'affaire pour moi.

+0

Merci beaucoup. Ça a marché!! – madcoderz

2

Appliquer la marge ou de rembourrage, par exemple:

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

Ou:

<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" 
    /> 

Cela pourrait être utile pour vous: Difference between a View's Padding and Margin

+0

J'ai essayé le rembourrage mais cela n'a pas fonctionné, et la marge n'est pas appropriée dans ce cas parce que les boutons ne sont pas centrés. Aucune suggestion? – madcoderz

+0

Qu'est-ce qui n'a pas fonctionné au sujet du rembourrage? – Falmarri

+0

Et qu'est-ce que la marge a à voir avec être centré? Pour – Falmarri

Questions connexes