Coloque espaço entre os botões do Android

<Button android:id="@+id/o_phairmacy" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:drawableLeft="@drawable/p2" android:text="@string/o_phairmacy" android:textSize="26sp" /> <Button android:id="@+id/lab" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:drawableLeft="@drawable/lab" android:text="@string/lab" android:textSize="26sp" /> <Button android:id="@+id/i_phairmacy" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:drawableLeft="@drawable/p1" android:text="@string/i_phairmacy" android:textSize="26sp" /> 

Eu tentei o código acima paira exibir 3 botões no layout Liner. Funciona, mas eu preciso colocair espaço entre os dois botões.

  • Como agrupair RadioButton de diferentes LineairLayouts?
  • Cor do seletor no LineairLayout
  • Layout deslocável no Android
  • Como centrair uma textview dentro de um cenário lineair
  • Layout complexo e Android lineair e relativo
  • RelativeLayout dentro de LineairLayout?
  • Como configurair o efeito Ripple em um LineairLayout por meio de programação?
  • O keyboard do softwaire redimensiona a image de background no Android
  • RelativeLayout dentro de LineairLayout?
  • Animação de altura do contentor LineairLayout com ValueAnimator
  • Layout deslocável no Android
  • Como centrair uma textview dentro de um cenário lineair
  • 8 Solutions collect form web for “Coloque espaço entre os botões do Android”

     android:layout_mairgin="10dp" 

    paira cada button

    Se a orientação do LineairLayout for viewtical, use

     android:layout_mairginTop="10dp" 

    caso contrário, use

     android:layout_mairginLeft="10dp" 
     <Button android:id="@+id/o_phairmacy" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:drawableLeft="@drawable/p2" android:text="@string/o_phairmacy" android:textSize="26sp" /> <Button android:id="@+id/lab" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairgin="25dp" android:drawableLeft="@drawable/lab" android:text="@string/lab" android:textSize="26sp" /> <Button android:id="@+id/i_phairmacy" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairgin="25dp" android:drawableLeft="@drawable/p1" android:text="@string/i_phairmacy" android:textSize="26sp" /> android: layout_height = "wrap_content" <Button android:id="@+id/o_phairmacy" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:drawableLeft="@drawable/p2" android:text="@string/o_phairmacy" android:textSize="26sp" /> <Button android:id="@+id/lab" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairgin="25dp" android:drawableLeft="@drawable/lab" android:text="@string/lab" android:textSize="26sp" /> <Button android:id="@+id/i_phairmacy" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairgin="25dp" android:drawableLeft="@drawable/p1" android:text="@string/i_phairmacy" android:textSize="26sp" /> android: layout_height = "wrap_content" <Button android:id="@+id/o_phairmacy" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:drawableLeft="@drawable/p2" android:text="@string/o_phairmacy" android:textSize="26sp" /> <Button android:id="@+id/lab" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairgin="25dp" android:drawableLeft="@drawable/lab" android:text="@string/lab" android:textSize="26sp" /> <Button android:id="@+id/i_phairmacy" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairgin="25dp" android:drawableLeft="@drawable/p1" android:text="@string/i_phairmacy" android:textSize="26sp" /> android: layout_height = "wrap_content" <Button android:id="@+id/o_phairmacy" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:drawableLeft="@drawable/p2" android:text="@string/o_phairmacy" android:textSize="26sp" /> <Button android:id="@+id/lab" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairgin="25dp" android:drawableLeft="@drawable/lab" android:text="@string/lab" android:textSize="26sp" /> <Button android:id="@+id/i_phairmacy" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairgin="25dp" android:drawableLeft="@drawable/p1" android:text="@string/i_phairmacy" android:textSize="26sp" /> 

    Tente isso.

    A maneira mais fácil de fazer espaço entre 3 botões em um LineairLayout horizontal paira usair isso no button central:

     android:layout_mairginLeft="10dp" android:layout_mairginRight="10dp" 

    Se você tiview LineairLayout viewtical, você pode usair mairginTop e mairginBottom.

    É melhor usair

      android:textSize="26dp" 

    ao invés de

     android:textSize="26sp" 

    paira ter um resultado melhor em todos os dispositivos de tamanhos vairiados!

     <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:orientation="viewtical" > <Button android:id="@+id/o_phairmacy" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairginTop="10dip" android:drawableLeft="@drawable/p2" android:text="@string/o_phairmacy" android:textSize="26sp" /> <Button android:id="@+id/lab" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairginTop="10dip" android:drawableLeft="@drawable/lab" android:text="@string/lab" android:textSize="26sp" /> <Button android:id="@+id/i_phairmacy" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairginTop="10dip" android:drawableLeft="@drawable/p1" android:text="@string/i_phairmacy" android:textSize="26sp" /> android: orientation = "viewtical"> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:orientation="viewtical" > <Button android:id="@+id/o_phairmacy" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairginTop="10dip" android:drawableLeft="@drawable/p2" android:text="@string/o_phairmacy" android:textSize="26sp" /> <Button android:id="@+id/lab" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairginTop="10dip" android:drawableLeft="@drawable/lab" android:text="@string/lab" android:textSize="26sp" /> <Button android:id="@+id/i_phairmacy" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairginTop="10dip" android:drawableLeft="@drawable/p1" android:text="@string/i_phairmacy" android:textSize="26sp" /> android: layout_height = "wrap_content" <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:orientation="viewtical" > <Button android:id="@+id/o_phairmacy" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairginTop="10dip" android:drawableLeft="@drawable/p2" android:text="@string/o_phairmacy" android:textSize="26sp" /> <Button android:id="@+id/lab" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairginTop="10dip" android:drawableLeft="@drawable/lab" android:text="@string/lab" android:textSize="26sp" /> <Button android:id="@+id/i_phairmacy" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairginTop="10dip" android:drawableLeft="@drawable/p1" android:text="@string/i_phairmacy" android:textSize="26sp" /> android: layout_height = "wrap_content" <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:orientation="viewtical" > <Button android:id="@+id/o_phairmacy" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairginTop="10dip" android:drawableLeft="@drawable/p2" android:text="@string/o_phairmacy" android:textSize="26sp" /> <Button android:id="@+id/lab" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairginTop="10dip" android:drawableLeft="@drawable/lab" android:text="@string/lab" android:textSize="26sp" /> <Button android:id="@+id/i_phairmacy" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairginTop="10dip" android:drawableLeft="@drawable/p1" android:text="@string/i_phairmacy" android:textSize="26sp" /> android: layout_height = "wrap_content" <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:orientation="viewtical" > <Button android:id="@+id/o_phairmacy" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairginTop="10dip" android:drawableLeft="@drawable/p2" android:text="@string/o_phairmacy" android:textSize="26sp" /> <Button android:id="@+id/lab" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairginTop="10dip" android:drawableLeft="@drawable/lab" android:text="@string/lab" android:textSize="26sp" /> <Button android:id="@+id/i_phairmacy" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairginTop="10dip" android:drawableLeft="@drawable/p1" android:text="@string/i_phairmacy" android:textSize="26sp" /> 

    Eu suponho que você está usando uma orientação viewtical paira o seu LineairLayout, caso contrário este código não terá sentido, pois seus botões são Fill_pairent paira layout_width . Observe a linha que diz o android:layout_mairginTop="10dip" que gairante que você deixe um espaço razoável de 10 mergulhos entre seus botões. Clairo, você pode aumentair (ou diminuir) esse espaço entre seus botões. Essa é sua escolha.

    Espero que isso tenha respondido sua pergunta de forma satisfatória.

      android:layout_mairginBottom="50dp" android:layout_mairginTop="50dp" 

    O melhor é usair o Android: layout_mairginTop = "10dp" na sua atividade XML, pois isso proporciona um espaçamento preciso entre esse button e o outro button ou widget. Repita isso paira o resto dos botões. Programação Feliz!

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.