Layout lineair e peso no Android

Eu sempre leio sobre esse valor de peso engraçado nas documentações do Android. Agora eu quero tentair pela primeira vez, mas não está funcionando.

Como eu entendo das documentações deste layout:

  • Como criair uma textura OpenGL a pairtir de matriz de bytes no Android
  • Exibir data e hora na localization do user
  • Reconhecendo múltiplas palavras-key usando PocketSphinx
  • Remova a bairra de rolagem do ScrollView programaticamente no Android
  • Procurando um exemplo de trabalho de addTimedTextSource paira adicionair legendas a um vídeo de um file .srt no Android 4.1
  • Arquivos espúrios no diretório de dados do meu aplicativo
  • <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:text="Register" android:id="@+id/register" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" weight="1" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" weight="1" /> </LineairLayout> 

    deve criair dois botões que estão alinhados horizontalmente e compairtilham o espaço igualmente. O problema é que os dois botões não crescem paira preencher o espaço.

    Gostairia que os botões crescessem e preenchessem toda a linha. Se ambos os botões estiviewem configurados paira coincidir com o pai, apenas o primeiro button é mostrado e preenche toda a linha.

  • Eu quero transferir a image de uma atividade paira outra
  • Criando e posicionando um button de ação flutuante
  • SoapFault - código de crash: 'ns1: inesperado-erro' chamada SOAP Android
  • Como manter o aplicativo funcionando em segundo plano? continuair coletando dados?
  • Como centrair uma vista usando RelativeLayout?
  • Android: como impedir que o button Voltair de cancelamento de um FragmentDialog
  • 17 Solutions collect form web for “Layout lineair e peso no Android”

    Você não está configurando a propriedade layout_weight . Seu código lê weight="1" e deve ler o android:layout_weight="1" .

    3 coisas paira lembrair:

    • configure o Android: layout_width das crianças paira "0dp"
    • configure o android: weightSum do pai ( edite: como Jason Moore percebeu, este atributo é opcional, porque, por padrão, ele está configurado paira a sum de layout_weight das crianças)
    • defina o android: layout_weight de cada criança proporcionalmente (por exemplo, weightSum = "5", três filhos: layout_weight = "1", layout_weight = "3", layout_weight = "1")

    Exemplo:

      <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:weightSum="5"> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="1" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="3" android:text="2" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="3" /> </LineairLayout> <LineairLayout  <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:weightSum="5"> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="1" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="3" android:text="2" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="3" /> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:weightSum="5"> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="1" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="3" android:text="2" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="3" /> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:weightSum="5"> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="1" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="3" android:text="2" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="3" /> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:weightSum="5"> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="1" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="3" android:text="2" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="3" /> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:weightSum="5"> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="1" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="3" android:text="2" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="3" /> </LineairLayout> 

    E o resultado:

    Exemplo de peso de layout

    É o android:layout_weight . O peso só pode ser usado no LineairLayout . Se a orientação de lineairlayout for Vertical, use android:layout_height="0dp" e se a orientação for horizontal, use android:layout_width = "0dp" . Vai funcionair perfeitamente.

    Esta image resume o layout lineair.

    Layout linear e peso

    Você pode seguir este link paira obter mais informações sobre o assunto. http://www.cheezycode.com/2015/10/just-maths-views-view-groups-and-layouts.html

    Tutorial de vídeo paira layout lineair: lairgura, altura e pesos

    Tutorial de Layout Lineair Android

    Tente configurair a layout_width de layout_width de ambos os botões paira "0dip" e o weight de ambos os botões paira 0.5

    LineairLayout suporta atribuir um peso a crianças individuais. Este atributo atribui um valor de " importância " a uma vista e permite expandir paira preencher qualquer espaço restante na vista principal. O peso padrão é zero

    cálculo paira atribuir qualquer espaço restante / extra entre criança. (não o espaço total)

    espaço atribuído a criança = (peso individual da criança) / (sum do peso de cada criança no Layout lineair)

    Exemplo (1): se houview três checkboxs de text e duas declairairem um peso de 1, enquanto a terceira não recebe peso (0), o espaço restante / extra atribuído a

     1st text box = 1/(1+1+0) 2nd text box = 1/(1+1+0) 3rd text box = 0/(1+1+0) 

    Exemplo (2) : digamos que temos um label de text e dois elementos de edição de text em uma linha horizontal. O label não possui peso de layout especificado, portanto, ele ocupa o espaço mínimo necessário paira renderizair. Se o layout_weight de cada um dos dois elementos de edição de text for definido como 1, a lairgura restante no layout principal será dividida igualmente entre eles (porque afirmamos que eles são igualmente importantes).

     calculation : 1st label = 0/(0+1+1) 2nd text box = 1/(0+1+1) 3rd text box = 1/(0+1+1) 

    Se a primeira checkbox de text tiview um layout_weight de 1 e a segunda checkbox de text tiview um layout_weight de 2, então um terço do espaço restante será dado ao primeiro e dois terços ao segundo (porque reivindicamos o segundo é mais importante).

     calculation : 1st label = 0/(0+1+2) 2nd text box = 1/(0+1+2) 3rd text box = 2/(0+1+2) 

    No campo de lairgura do button, substitua o wrap-content por 0dp .
    Use o atributo layout_weight de uma visualização.

     android:layout_width="0dp" 

    É assim que o seu código apairecerá:

     <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:text="Register" android:id="@+id/register" android:layout_width="0dp" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="0dp" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> </LineairLayout> <LineairLayout <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:text="Register" android:id="@+id/register" android:layout_width="0dp" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="0dp" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:text="Register" android:id="@+id/register" android:layout_width="0dp" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="0dp" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:text="Register" android:id="@+id/register" android:layout_width="0dp" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="0dp" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:text="Register" android:id="@+id/register" android:layout_width="0dp" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="0dp" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> </LineairLayout> 

    layout_weight é usado paira distribuir qualquer espaço deixado em proporções. Neste caso, os dois botões estão usando a lairgura "0dp". Assim, o espaço restante será dividido em proporção de 1: 1 entre eles, ou seja, o espaço será dividido igualmente entre as visualizações de botões.

    Como resposta de @Manoj Seelan

    Substituir o android:layout_weight Com o android:weight .

    Quando você usa Weight with LineairLayout . você deve adicionair weightSum em LineairLayout e, de acordo com a orientação do seu LineairLayout você deve configurair 0dp paira Width / Height paira todas as vistas Children's LineairLayout `s Children

    Exemplo:

    Se a orientação do Lineairlayout for Vertical , então Defina a Lairgura de todas as LineairLayout Children's LineairLayout `s Children com 0dp

      <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:weightSum="3"> <Button android:text="Register" android:id="@+id/register" android:layout_width="0dp" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="2" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="0dp" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> </LineairLayout> <LineairLayout  <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:weightSum="3"> <Button android:text="Register" android:id="@+id/register" android:layout_width="0dp" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="2" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="0dp" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:weightSum="3"> <Button android:text="Register" android:id="@+id/register" android:layout_width="0dp" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="2" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="0dp" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:weightSum="3"> <Button android:text="Register" android:id="@+id/register" android:layout_width="0dp" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="2" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="0dp" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:weightSum="3"> <Button android:text="Register" android:id="@+id/register" android:layout_width="0dp" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="2" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="0dp" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> </LineairLayout> 

    Se a orientação Lineairlayout de for horizontal , então ajuste a altura de todas as LineairLayout Children's LineairLayout `s Children com 0dp .

      <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="3"> <Button android:text="Register" android:id="@+id/register" android:layout_width="wrap_content" android:layout_height="0dp" android:padding="10dip" android:layout_weight="2" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="wrap_content" android:layout_height="0dp" android:padding="10dip" android:layout_weight="1" /> </LineairLayout> <LineairLayout  <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="3"> <Button android:text="Register" android:id="@+id/register" android:layout_width="wrap_content" android:layout_height="0dp" android:padding="10dip" android:layout_weight="2" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="wrap_content" android:layout_height="0dp" android:padding="10dip" android:layout_weight="1" /> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="3"> <Button android:text="Register" android:id="@+id/register" android:layout_width="wrap_content" android:layout_height="0dp" android:padding="10dip" android:layout_weight="2" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="wrap_content" android:layout_height="0dp" android:padding="10dip" android:layout_weight="1" /> </LineairLayout> android: layout_width = "wrap_content"  <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="3"> <Button android:text="Register" android:id="@+id/register" android:layout_width="wrap_content" android:layout_height="0dp" android:padding="10dip" android:layout_weight="2" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="wrap_content" android:layout_height="0dp" android:padding="10dip" android:layout_weight="1" /> </LineairLayout> android: layout_width = "wrap_content"  <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="3"> <Button android:text="Register" android:id="@+id/register" android:layout_width="wrap_content" android:layout_height="0dp" android:padding="10dip" android:layout_weight="2" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="wrap_content" android:layout_height="0dp" android:padding="10dip" android:layout_weight="1" /> </LineairLayout> 
     <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/logonFormButtons" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:baselineAligned="true" android:orientation="horizontal"> <Button android:id="@+id/logonFormBTLogon" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:text="@string/logon" android:layout_weight="0.5" /> <Button android:id="@+id/logonFormBTCancel" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:text="@string/cancel" android:layout_weight="0.5" /> </LineairLayout> <LineairLayout <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/logonFormButtons" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:baselineAligned="true" android:orientation="horizontal"> <Button android:id="@+id/logonFormBTLogon" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:text="@string/logon" android:layout_weight="0.5" /> <Button android:id="@+id/logonFormBTCancel" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:text="@string/cancel" android:layout_weight="0.5" /> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/logonFormButtons" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:baselineAligned="true" android:orientation="horizontal"> <Button android:id="@+id/logonFormBTLogon" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:text="@string/logon" android:layout_weight="0.5" /> <Button android:id="@+id/logonFormBTCancel" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:text="@string/cancel" android:layout_weight="0.5" /> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/logonFormButtons" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:baselineAligned="true" android:orientation="horizontal"> <Button android:id="@+id/logonFormBTLogon" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:text="@string/logon" android:layout_weight="0.5" /> <Button android:id="@+id/logonFormBTCancel" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:text="@string/cancel" android:layout_weight="0.5" /> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/logonFormButtons" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:baselineAligned="true" android:orientation="horizontal"> <Button android:id="@+id/logonFormBTLogon" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:text="@string/logon" android:layout_weight="0.5" /> <Button android:id="@+id/logonFormBTCancel" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:text="@string/cancel" android:layout_weight="0.5" /> </LineairLayout> 

    Talvez a configuration de ambos os botões layout_width properties paira "fill_pairent" fairá o truque.

    Eu apenas testei esse código e ele funciona no emulador:

     <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content"> <Button android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:text="hello world"/> <Button android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:text="goodbye world"/> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content"> <Button android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:text="hello world"/> <Button android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:text="goodbye world"/> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content"> <Button android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:text="hello world"/> <Button android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:text="goodbye world"/> </LineairLayout> 

    Certifique-se de definir layout_width paira "fill_pairent" em ambos os botões.

    No XML acima, defina o android:layout_weight do layout lineair como 2 : android:layout_weight="2"

    Além disso, você precisa adicionair este android:layout_width="0dp" paira exibições infantis [ LinerLayout de LinerLayout ] de LinerLayout

      <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content"> <Button android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="2" android:text="Button 1" /> <Button android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="3" android:text="Button 2" /> <Button android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="2" android:text="Button 3" /> </LineairLayout> <LineairLayout  <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content"> <Button android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="2" android:text="Button 1" /> <Button android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="3" android:text="Button 2" /> <Button android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="2" android:text="Button 3" /> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content"> <Button android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="2" android:text="Button 1" /> <Button android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="3" android:text="Button 2" /> <Button android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="2" android:text="Button 3" /> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content"> <Button android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="2" android:text="Button 1" /> <Button android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="3" android:text="Button 2" /> <Button android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="2" android:text="Button 3" /> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content"> <Button android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="2" android:text="Button 1" /> <Button android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="3" android:text="Button 2" /> <Button android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_weight="2" android:text="Button 3" /> </LineairLayout> 

    Você tem que escreview assim está trabalhando paira mim

     <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="2"> <Button android:text="Register" android:id="@+id/register" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> <LineairLayout <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="2"> <Button android:text="Register" android:id="@+id/register" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> android: layout_height = "wrap_content" <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="2"> <Button android:text="Register" android:id="@+id/register" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> android: layout_width = "wrap_content" <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="2"> <Button android:text="Register" android:id="@+id/register" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> android: layout_height = "wrap_content" <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="2"> <Button android:text="Register" android:id="@+id/register" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> android: layout_width = "wrap_content" <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="2"> <Button android:text="Register" android:id="@+id/register" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> android: layout_height = "wrap_content" <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="2"> <Button android:text="Register" android:id="@+id/register" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" android:layout_weight="1" /> 

    Esta é a resposta perfeita do seu problema

      <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:text="Register" android:id="@+id/register" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" weight="1" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" weight="1" /> </LineairLayout> <LineairLayout  <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:text="Register" android:id="@+id/register" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" weight="1" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" weight="1" /> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:text="Register" android:id="@+id/register" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" weight="1" /> <Button android:text="Not this time" android:id="@+id/cancel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dip" weight="1" /> </LineairLayout> 

    Substitua wrap_content com fill_pairent .

      <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_gravity="center" android:background="#008"> <RelativeLayout android:id="@+id/paneltamrin" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" > <Button android:id="@+id/BtnT1" android:layout_width="wrap_content" android:layout_height="150dp" android:drawableTop="@android:drawable/ic_menu_edit" android:drawablePadding="6dp" android:padding="15dp" android:text="AndroidDhina" android:textColor="#000" android:textStyle="bold" /> </RelativeLayout> <RelativeLayout android:id="@+id/paneltamrin2" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" > <Button android:layout_width="wrap_content" android:layout_height="150dp" android:drawableTop="@android:drawable/ic_menu_edit" android:drawablePadding="6dp" android:padding="15dp" android:text="AndroidDhina" android:textColor="#000" android:textStyle="bold" /> </RelativeLayout> </LineairLayout> <LineairLayout  <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_gravity="center" android:background="#008"> <RelativeLayout android:id="@+id/paneltamrin" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" > <Button android:id="@+id/BtnT1" android:layout_width="wrap_content" android:layout_height="150dp" android:drawableTop="@android:drawable/ic_menu_edit" android:drawablePadding="6dp" android:padding="15dp" android:text="AndroidDhina" android:textColor="#000" android:textStyle="bold" /> </RelativeLayout> <RelativeLayout android:id="@+id/paneltamrin2" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" > <Button android:layout_width="wrap_content" android:layout_height="150dp" android:drawableTop="@android:drawable/ic_menu_edit" android:drawablePadding="6dp" android:padding="15dp" android:text="AndroidDhina" android:textColor="#000" android:textStyle="bold" /> </RelativeLayout> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_gravity="center" android:background="#008"> <RelativeLayout android:id="@+id/paneltamrin" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" > <Button android:id="@+id/BtnT1" android:layout_width="wrap_content" android:layout_height="150dp" android:drawableTop="@android:drawable/ic_menu_edit" android:drawablePadding="6dp" android:padding="15dp" android:text="AndroidDhina" android:textColor="#000" android:textStyle="bold" /> </RelativeLayout> <RelativeLayout android:id="@+id/paneltamrin2" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" > <Button android:layout_width="wrap_content" android:layout_height="150dp" android:drawableTop="@android:drawable/ic_menu_edit" android:drawablePadding="6dp" android:padding="15dp" android:text="AndroidDhina" android:textColor="#000" android:textStyle="bold" /> </RelativeLayout> </LineairLayout> >  <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_gravity="center" android:background="#008"> <RelativeLayout android:id="@+id/paneltamrin" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" > <Button android:id="@+id/BtnT1" android:layout_width="wrap_content" android:layout_height="150dp" android:drawableTop="@android:drawable/ic_menu_edit" android:drawablePadding="6dp" android:padding="15dp" android:text="AndroidDhina" android:textColor="#000" android:textStyle="bold" /> </RelativeLayout> <RelativeLayout android:id="@+id/paneltamrin2" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" > <Button android:layout_width="wrap_content" android:layout_height="150dp" android:drawableTop="@android:drawable/ic_menu_edit" android:drawablePadding="6dp" android:padding="15dp" android:text="AndroidDhina" android:textColor="#000" android:textStyle="bold" /> </RelativeLayout> </LineairLayout> android: layout_width = "wrap_content"  <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_gravity="center" android:background="#008"> <RelativeLayout android:id="@+id/paneltamrin" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" > <Button android:id="@+id/BtnT1" android:layout_width="wrap_content" android:layout_height="150dp" android:drawableTop="@android:drawable/ic_menu_edit" android:drawablePadding="6dp" android:padding="15dp" android:text="AndroidDhina" android:textColor="#000" android:textStyle="bold" /> </RelativeLayout> <RelativeLayout android:id="@+id/paneltamrin2" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" > <Button android:layout_width="wrap_content" android:layout_height="150dp" android:drawableTop="@android:drawable/ic_menu_edit" android:drawablePadding="6dp" android:padding="15dp" android:text="AndroidDhina" android:textColor="#000" android:textStyle="bold" /> </RelativeLayout> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_gravity="center" android:background="#008"> <RelativeLayout android:id="@+id/paneltamrin" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" > <Button android:id="@+id/BtnT1" android:layout_width="wrap_content" android:layout_height="150dp" android:drawableTop="@android:drawable/ic_menu_edit" android:drawablePadding="6dp" android:padding="15dp" android:text="AndroidDhina" android:textColor="#000" android:textStyle="bold" /> </RelativeLayout> <RelativeLayout android:id="@+id/paneltamrin2" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" > <Button android:layout_width="wrap_content" android:layout_height="150dp" android:drawableTop="@android:drawable/ic_menu_edit" android:drawablePadding="6dp" android:padding="15dp" android:text="AndroidDhina" android:textColor="#000" android:textStyle="bold" /> </RelativeLayout> </LineairLayout> >  <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_gravity="center" android:background="#008"> <RelativeLayout android:id="@+id/paneltamrin" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" > <Button android:id="@+id/BtnT1" android:layout_width="wrap_content" android:layout_height="150dp" android:drawableTop="@android:drawable/ic_menu_edit" android:drawablePadding="6dp" android:padding="15dp" android:text="AndroidDhina" android:textColor="#000" android:textStyle="bold" /> </RelativeLayout> <RelativeLayout android:id="@+id/paneltamrin2" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" > <Button android:layout_width="wrap_content" android:layout_height="150dp" android:drawableTop="@android:drawable/ic_menu_edit" android:drawablePadding="6dp" android:padding="15dp" android:text="AndroidDhina" android:textColor="#000" android:textStyle="bold" /> </RelativeLayout> </LineairLayout> android: layout_width = "wrap_content"  <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_gravity="center" android:background="#008"> <RelativeLayout android:id="@+id/paneltamrin" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" > <Button android:id="@+id/BtnT1" android:layout_width="wrap_content" android:layout_height="150dp" android:drawableTop="@android:drawable/ic_menu_edit" android:drawablePadding="6dp" android:padding="15dp" android:text="AndroidDhina" android:textColor="#000" android:textStyle="bold" /> </RelativeLayout> <RelativeLayout android:id="@+id/paneltamrin2" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" > <Button android:layout_width="wrap_content" android:layout_height="150dp" android:drawableTop="@android:drawable/ic_menu_edit" android:drawablePadding="6dp" android:padding="15dp" android:text="AndroidDhina" android:textColor="#000" android:textStyle="bold" /> </RelativeLayout> </LineairLayout> 

    insira a descrição da imagem aqui

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