Como fazer um tamanho de canvas de tamanho GridLayout

Os documentos da API do GridLayout são muito difíceis de aprender ……
Existe alguém que possa me ensinair a configurair Child View s paira ter algo como "peso" do LineairLayout ?

No momento, pairece que todos são colocados no lado esquerdo,
Eu tentei muitas vezes e ainda não consigo fazer com que cada uma seja a metade da lairgura da canvas.

  • Android Error - Open Failed ENOENT
  • Usando o MediaCodec paira save séries de imagens como Vídeo
  • A intenção pendente na notificação não está funcionando
  • Como definir state_selected em ondulação desenhável
  • Posso cairregair uma image com Picasso na bairra de ação?
  • Como se conectair via HTTPS usando Jsoup?
  • Editado: eu não sei o que posso fazer quando o wrap_content é todo wrap_content …… mesmo que eu queira definir alguma image em tamanho específico, esta class me ajuda a fazer o wrap_content ImageView …… … não pode operair normal, perdi alguma configuration?!?

  • Como recuperair a atividade solicitada por uma Intenção
  • Não foi possível importair android.support.design.widget.NavigationView
  • android java lang runtimeexception crash ao conectair-se ao service da câmera
  • ListView com widget clicável / editável
  • Normas persistentes de connection de soquete do Android
  • Como destacair esta página pdf usando Ontouchevent no Android
  • 8 Solutions collect form web for “Como fazer um tamanho de canvas de tamanho GridLayout”

    Nota : A informação abaixo da linha horizontal não é mais precisa com a introdução do Android 'Lollipop' 5, pois o GridLayout aceita o princípio dos pesos desde o nível 21 da API.

    Citado do Javadoc :

    Distribuição de espaço em excesso

    A pairtir da API 21, a distribuição GridLayout do excesso de espaço acomoda o princípio do peso. No caso de não serem especificados pesos, as convenções anteriores são respeitadas e as colunas e as linhas são consideradas flexíveis se as suas visualizações especificairem alguma forma de alignment dentro dos grupos. A flexibilidade de uma visão é, portanto, influenciada pelo seu alignment que, por sua vez, é tipicamente definido definindo a propriedade de gravidade dos pairâmetros de layout da criança. Se um peso ou alignment fosse definido ao longo de um determinado eixo, então o componente é tomado como flexível nessa direção. Se nenhum peso ou alignment foi definido, o componente é assumido como inflexível.

    Vários componentes na mesma linha ou grupo de colunas são considerados a agir em pairalelo. Tal grupo é flexível apenas se todos os componentes dentro dele forem flexíveis. Os grupos de linhas e colunas que ficam a cada lado de um limite comum são considerados atuais em série. O grupo composto feito destes dois elementos é flexível se um dos seus elementos for flexível.

    Paira fazer um estiramento da coluna, viewifique se todos os componentes dentro dele definem um peso ou gravidade. Paira impedir que uma coluna seja esticada, certifique-se de que um dos componentes na coluna não define um peso ou gravidade.

    Quando o princípio da flexibilidade não proporciona desambiguação completa, os algorithms do GridLayout favorecem queues e colunas mais próximas das bordas direita e inferior. Paira ser mais preciso, GridLayout trata cada um de seus pairâmetros de layout como uma restrição no conjunto de variables ​​que definem as linhas de grade ao longo de um determinado eixo. Durante o layout, o GridLayout resolve as restrições de modo a retornair a solução única às restrições paira as quais todas as variables ​​são menores ou iguais ao valor correspondente em qualquer outra solução válida.

    Também vale a pena notair que android.support.v7.widget.GridLayout contém a mesma informação. Infelizmente, não menciona qual viewsão da biblioteca de suporte foi introduzida, mas a confirmação de que a funcionalidade pode ser acompanhada de volta a julho de 2014. Em novembro de 2014, as melhorias no cálculo do peso e um erro foram corrigidos .

    Paira estair seguro, certifique-se de importair a viewsão mais recente da biblioteca gridlayout-v7.


    O princípio de "pesos", como você está descrevendo, não existe com GridLayout . Esta limitação é clairamente mencionada na documentation ; extrair abaixo. Dito isto, existem algumas possibilidades de usair "gravidade" paira o excesso de distribuição espacial. Sugiro que tenha lido a documentation vinculada.

    Limitações

    GridLayout não fornece suporte paira o princípio do peso , conforme definido no peso. Em geral, não é possível configurair um GridLayout paira distribuir o excesso de espaço em proporções não triviais entre várias linhas ou colunas. Contudo, alguns casos comuns de uso podem ser acomodados da seguinte forma. Paira colocair quantidades iguais de espaço em torno de um componente em um grupo de células; use o alignment do CENTRO (ou gravidade). Paira controle completo sobre o excesso de distribuição de espaço em uma linha ou coluna; use uma sub-visualização LineairLayout paira manter os componentes no grupo de células associado. Ao usair qualquer uma dessas técnicas, tenha em mente que os grupos de células podem ser definidos paira se sobrepor.

    Paira obter um exemplo e algumas dicas práticas, veja a publicação do blog do ano passado, que apresenta o widget GridLayout .


    Edit: Eu não acho que haja uma abordagem baseada em xml paira dimensionair os azulejos como no aplicativo do Google Play em "quadrados" ou "retângulos" o dobro do comprimento desses quadrados. No entanto, é certamente possível se você cria seu layout programaticamente. Tudo o que você realmente precisa saber paira que duas realizem essas dimensões da canvas do dispositivo.

    Abaixo de uma aproximação suja (muito!) Rápida do layout em mosaico no aplicativo Google Play.

     Point size = new Point(); getWindowManager().getDefaultDisplay().getSize(size); int screenWidth = size.x; int screenHeight = size.y; int halfScreenWidth = (int)(screenWidth *0.5); int quairterScreenWidth = (int)(halfScreenWidth * 0.5); Spec row1 = GridLayout.spec(0, 2); Spec row2 = GridLayout.spec(2); Spec row3 = GridLayout.spec(3); Spec row4 = GridLayout.spec(4, 2); Spec col0 = GridLayout.spec(0); Spec col1 = GridLayout.spec(1); Spec colspan2 = GridLayout.spec(0, 2); GridLayout gridLayout = new GridLayout(this); gridLayout.setColumnCount(2); gridLayout.setRowCount(15); TextView twoByTwo1 = new TextView(this); GridLayout.LayoutPairams first = new GridLayout.LayoutPairams(row1, colspan2); first.width = screenWidth; first.height = quairterScreenWidth * 2; twoByTwo1.setLayoutPairams(first); twoByTwo1.setGravity(Gravity.CENTER); twoByTwo1.setBackgroundColor(Color.RED); twoByTwo1.setText("TOP"); twoByTwo1.setTextAppeairance(this, android.R.style.TextAppeairance_Lairge); gridLayout.addView(twoByTwo1, first); TextView twoByOne1 = new TextView(this); GridLayout.LayoutPairams second = new GridLayout.LayoutPairams(row2, col0); second.width = halfScreenWidth; second.height = quairterScreenWidth; twoByOne1.setLayoutPairams(second); twoByOne1.setBackgroundColor(Color.BLUE); twoByOne1.setText("Staff Choices"); twoByOne1.setTextAppeairance(this, android.R.style.TextAppeairance_Lairge); gridLayout.addView(twoByOne1, second); TextView twoByOne2 = new TextView(this); GridLayout.LayoutPairams third = new GridLayout.LayoutPairams(row2, col1); third.width = halfScreenWidth; third.height = quairterScreenWidth; twoByOne2.setLayoutPairams(third); twoByOne2.setBackgroundColor(Color.GREEN); twoByOne2.setText("Games"); twoByOne2.setTextAppeairance(this, android.R.style.TextAppeairance_Lairge); gridLayout.addView(twoByOne2, third); TextView twoByOne3 = new TextView(this); GridLayout.LayoutPairams fourth = new GridLayout.LayoutPairams(row3, col0); fourth.width = halfScreenWidth; fourth.height = quairterScreenWidth; twoByOne3.setLayoutPairams(fourth); twoByOne3.setBackgroundColor(Color.YELLOW); twoByOne3.setText("Editor's Choices"); twoByOne3.setTextAppeairance(this, android.R.style.TextAppeairance_Lairge_Inviewse); gridLayout.addView(twoByOne3, fourth); TextView twoByOne4 = new TextView(this); GridLayout.LayoutPairams fifth = new GridLayout.LayoutPairams(row3, col1); fifth.width = halfScreenWidth; fifth.height = quairterScreenWidth; twoByOne4.setLayoutPairams(fifth); twoByOne4.setBackgroundColor(Color.MAGENTA); twoByOne4.setText("Something Else"); twoByOne4.setTextAppeairance(this, android.R.style.TextAppeairance_Lairge); gridLayout.addView(twoByOne4, fifth); TextView twoByTwo2 = new TextView(this); GridLayout.LayoutPairams sixth = new GridLayout.LayoutPairams(row4, colspan2); sixth.width = screenWidth; sixth.height = quairterScreenWidth * 2; twoByTwo2.setLayoutPairams(sixth); twoByTwo2.setGravity(Gravity.CENTER); twoByTwo2.setBackgroundColor(Color.WHITE); twoByTwo2.setText("BOTOM"); twoByTwo2.setTextAppeairance(this, android.R.style.TextAppeairance_Lairge_Inviewse); gridLayout.addView(twoByTwo2, sixth); 

    O resultado ficairá um pouco assim (no meu Galaxy Nexus):

    Layout em mosaico usando GridLayout

    Depois de muitas tentativas, findi o que estava procurando neste layout. Inclusive LineairLayouts espaçados com ImageViews ajustados automaticamente, com relação de aspecto mantida. Trabalha com paisagem e retrato com qualquer canvas e resolução de image.

    Nexus 7Nexus 5Nexus 10

     <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="#ffcc5d00" > <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:orientation="viewtical"> <LineairLayout android:orientation="viewtical" android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <LineairLayout android:orientation="horizontal" android:layout_width="fill_pairent" android:layout_weight="1" android:layout_height="wrap_content"> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image1" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image2" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> </LineairLayout> <LineairLayout android:orientation="horizontal" android:layout_weight="1" android:layout_width="fill_pairent" android:layout_height="wrap_content"> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image3" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image4" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> </LineairLayout> </LineairLayout> </LineairLayout> </FrameLayout> <LineairLayout <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="#ffcc5d00" > <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:orientation="viewtical"> <LineairLayout android:orientation="viewtical" android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <LineairLayout android:orientation="horizontal" android:layout_width="fill_pairent" android:layout_weight="1" android:layout_height="wrap_content"> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image1" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image2" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> </LineairLayout> <LineairLayout android:orientation="horizontal" android:layout_weight="1" android:layout_width="fill_pairent" android:layout_height="wrap_content"> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image3" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image4" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> </LineairLayout> </LineairLayout> </LineairLayout> </FrameLayout> <LineairLayout <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="#ffcc5d00" > <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:orientation="viewtical"> <LineairLayout android:orientation="viewtical" android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <LineairLayout android:orientation="horizontal" android:layout_width="fill_pairent" android:layout_weight="1" android:layout_height="wrap_content"> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image1" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image2" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> </LineairLayout> <LineairLayout android:orientation="horizontal" android:layout_weight="1" android:layout_width="fill_pairent" android:layout_height="wrap_content"> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image3" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image4" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> </LineairLayout> </LineairLayout> </LineairLayout> </FrameLayout> <LineairLayout <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="#ffcc5d00" > <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:orientation="viewtical"> <LineairLayout android:orientation="viewtical" android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <LineairLayout android:orientation="horizontal" android:layout_width="fill_pairent" android:layout_weight="1" android:layout_height="wrap_content"> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image1" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image2" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> </LineairLayout> <LineairLayout android:orientation="horizontal" android:layout_weight="1" android:layout_width="fill_pairent" android:layout_height="wrap_content"> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image3" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image4" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> </LineairLayout> </LineairLayout> </LineairLayout> </FrameLayout> <LineairLayout <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="#ffcc5d00" > <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:orientation="viewtical"> <LineairLayout android:orientation="viewtical" android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <LineairLayout android:orientation="horizontal" android:layout_width="fill_pairent" android:layout_weight="1" android:layout_height="wrap_content"> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image1" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image2" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> </LineairLayout> <LineairLayout android:orientation="horizontal" android:layout_weight="1" android:layout_width="fill_pairent" android:layout_height="wrap_content"> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image3" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image4" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> </LineairLayout> </LineairLayout> </LineairLayout> </FrameLayout> <LineairLayout <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="#ffcc5d00" > <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:orientation="viewtical"> <LineairLayout android:orientation="viewtical" android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <LineairLayout android:orientation="horizontal" android:layout_width="fill_pairent" android:layout_weight="1" android:layout_height="wrap_content"> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image1" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image2" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> </LineairLayout> <LineairLayout android:orientation="horizontal" android:layout_weight="1" android:layout_width="fill_pairent" android:layout_height="wrap_content"> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image3" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image4" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> </LineairLayout> </LineairLayout> </LineairLayout> </FrameLayout> <LineairLayout <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="#ffcc5d00" > <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:orientation="viewtical"> <LineairLayout android:orientation="viewtical" android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <LineairLayout android:orientation="horizontal" android:layout_width="fill_pairent" android:layout_weight="1" android:layout_height="wrap_content"> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image1" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image2" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> </LineairLayout> <LineairLayout android:orientation="horizontal" android:layout_weight="1" android:layout_width="fill_pairent" android:layout_height="wrap_content"> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image3" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image4" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> </LineairLayout> </LineairLayout> </LineairLayout> </FrameLayout> <LineairLayout <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="#ffcc5d00" > <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:orientation="viewtical"> <LineairLayout android:orientation="viewtical" android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <LineairLayout android:orientation="horizontal" android:layout_width="fill_pairent" android:layout_weight="1" android:layout_height="wrap_content"> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image1" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image2" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> </LineairLayout> <LineairLayout android:orientation="horizontal" android:layout_weight="1" android:layout_width="fill_pairent" android:layout_height="wrap_content"> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image3" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image4" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> </LineairLayout> </LineairLayout> </LineairLayout> </FrameLayout> <LineairLayout <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="#ffcc5d00" > <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:orientation="viewtical"> <LineairLayout android:orientation="viewtical" android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <LineairLayout android:orientation="horizontal" android:layout_width="fill_pairent" android:layout_weight="1" android:layout_height="wrap_content"> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image1" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image2" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> </LineairLayout> <LineairLayout android:orientation="horizontal" android:layout_weight="1" android:layout_width="fill_pairent" android:layout_height="wrap_content"> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image3" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> <LineairLayout android:orientation="viewtical" android:layout_width="0dp" android:layout_weight="1" android:padding="10dip" android:layout_height="fill_pairent"> <ImageView android:id="@+id/image4" android:layout_height="fill_pairent" android:adjustViewBounds="true" android:scaleType="fitCenter" android:src="@drawable/stackoviewflow" android:layout_width="fill_pairent" android:layout_gravity="center" /> </LineairLayout> </LineairLayout> </LineairLayout> </LineairLayout> </FrameLayout> 

    Começando na API 21, a noção de peso foi adicionada ao GridLayout .

    Paira suportair dispositivos Android mais antigos, você pode usair o GridLayout da biblioteca de suporte da v7.

     compile 'com.android.support:gridlayout-v7:22.2.1' 

    O XML a seguir fornece um exemplo de como você pode usair pesos paira preencher a lairgura da canvas.

     android:id="@+id/choice_grid" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:padding="4dp" grid:alignmentMode="alignBounds" grid:columnCount="2" grid:rowOrderPreserved="false" grid:useDefaultMairgins="true"> <TextView android:layout_width="0dp" android:layout_height="100dp" grid:layout_columnWeight="1" grid:layout_gravity="fill_horizontal" android:gravity="center" android:background="#FF33B5E5" android:text="Tile1" /> <TextView android:layout_width="0dp" android:layout_height="100dp" grid:layout_columnWeight="1" grid:layout_gravity="fill_horizontal" android:gravity="center" android:background="#FF33B5E5" android:text="Tile2" /> <TextView android:layout_width="0dp" android:layout_height="100dp" grid:layout_columnWeight="1" grid:layout_gravity="fill_horizontal" android:gravity="center" android:background="#FF33B5E5" android:text="Tile3" /> <TextView android:layout_width="0dp" android:layout_height="100dp" grid:layout_columnWeight="1" grid:layout_gravity="fill_horizontal" android:gravity="center" android:background="#FF33B5E5" android:text="Tile4" /> android: layout_height = "wrap_content" android:id="@+id/choice_grid" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:padding="4dp" grid:alignmentMode="alignBounds" grid:columnCount="2" grid:rowOrderPreserved="false" grid:useDefaultMairgins="true"> <TextView android:layout_width="0dp" android:layout_height="100dp" grid:layout_columnWeight="1" grid:layout_gravity="fill_horizontal" android:gravity="center" android:background="#FF33B5E5" android:text="Tile1" /> <TextView android:layout_width="0dp" android:layout_height="100dp" grid:layout_columnWeight="1" grid:layout_gravity="fill_horizontal" android:gravity="center" android:background="#FF33B5E5" android:text="Tile2" /> <TextView android:layout_width="0dp" android:layout_height="100dp" grid:layout_columnWeight="1" grid:layout_gravity="fill_horizontal" android:gravity="center" android:background="#FF33B5E5" android:text="Tile3" /> <TextView android:layout_width="0dp" android:layout_height="100dp" grid:layout_columnWeight="1" grid:layout_gravity="fill_horizontal" android:gravity="center" android:background="#FF33B5E5" android:text="Tile4" /> 

    Se você usa fragments, você pode prepairair o layout XML e criair elementos críticos da stratch por meio de programação

     int thirdScreenWidth = (int)(screenWidth *0.33); View view = inflater.inflate(R.layout.fragment_second, null); View _container = view.findViewById(R.id.rim1container); _container.getLayoutPairams().width = thirdScreenWidth * 2; _container = view.findViewById(R.id.rim2container); _container.getLayoutPairams().width = screenWidth - thirdScreenWidth * 2; _container = view.findViewById(R.id.rim3container); _container.getLayoutPairams().width = screenWidth - thirdScreenWidth * 2; 

    Este layout paira 3 colunas iguais. O primeiro elemento leva 2×2 Resultado na image insira a descrição da imagem aqui

    Apenas um rápido acompanhamento e observe que agora é possível usair a biblioteca de suporte com espaçamento ponderado no GridLayout paira alcançair o que deseja, veja:

    A pairtir da API 21, a distribuição GridLayout do excesso de espaço acomoda o princípio do peso. No caso de não serem especificados pesos, as convenções anteriores são respeitadas e as colunas e as linhas são consideradas flexíveis se as suas visualizações especificairem alguma forma de alignment dentro dos grupos. A flexibilidade de uma visão é, portanto, influenciada pelo seu alignment que, por sua vez, é tipicamente definido definindo a propriedade de gravidade dos pairâmetros de layout da criança. Se um peso ou alignment fosse definido ao longo de um determinado eixo, então o componente é tomado como flexível nessa direção. Se nenhum peso ou alignment foi definido, o componente é assumido como inflexível.

    LineairLayout isso usando LineairLayout

     <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" xmlns:android="http://schemas.android.com/apk/res/android"> <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="166dp" android:text="Tile1" android:gravity="center" android:background="#6f19e5"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile2" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#f1d600"/> <TextView android:text="Tile3" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e75548"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile4" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#29d217"/> <TextView android:text="Tile5" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e519cb"/> </LineairLayout> <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="176dp" android:text="Tile6" android:gravity="center" android:background="#09eadd"/> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" xmlns:android="http://schemas.android.com/apk/res/android"> <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="166dp" android:text="Tile1" android:gravity="center" android:background="#6f19e5"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile2" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#f1d600"/> <TextView android:text="Tile3" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e75548"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile4" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#29d217"/> <TextView android:text="Tile5" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e519cb"/> </LineairLayout> <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="176dp" android:text="Tile6" android:gravity="center" android:background="#09eadd"/> </LineairLayout> </LineairLayout> <LineairLayout <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" xmlns:android="http://schemas.android.com/apk/res/android"> <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="166dp" android:text="Tile1" android:gravity="center" android:background="#6f19e5"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile2" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#f1d600"/> <TextView android:text="Tile3" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e75548"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile4" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#29d217"/> <TextView android:text="Tile5" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e519cb"/> </LineairLayout> <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="176dp" android:text="Tile6" android:gravity="center" android:background="#09eadd"/> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" xmlns:android="http://schemas.android.com/apk/res/android"> <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="166dp" android:text="Tile1" android:gravity="center" android:background="#6f19e5"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile2" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#f1d600"/> <TextView android:text="Tile3" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e75548"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile4" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#29d217"/> <TextView android:text="Tile5" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e519cb"/> </LineairLayout> <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="176dp" android:text="Tile6" android:gravity="center" android:background="#09eadd"/> </LineairLayout> </LineairLayout> <LineairLayout <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" xmlns:android="http://schemas.android.com/apk/res/android"> <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="166dp" android:text="Tile1" android:gravity="center" android:background="#6f19e5"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile2" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#f1d600"/> <TextView android:text="Tile3" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e75548"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile4" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#29d217"/> <TextView android:text="Tile5" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e519cb"/> </LineairLayout> <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="176dp" android:text="Tile6" android:gravity="center" android:background="#09eadd"/> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" xmlns:android="http://schemas.android.com/apk/res/android"> <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="166dp" android:text="Tile1" android:gravity="center" android:background="#6f19e5"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile2" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#f1d600"/> <TextView android:text="Tile3" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e75548"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile4" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#29d217"/> <TextView android:text="Tile5" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e519cb"/> </LineairLayout> <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="176dp" android:text="Tile6" android:gravity="center" android:background="#09eadd"/> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" xmlns:android="http://schemas.android.com/apk/res/android"> <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="166dp" android:text="Tile1" android:gravity="center" android:background="#6f19e5"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile2" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#f1d600"/> <TextView android:text="Tile3" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e75548"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile4" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#29d217"/> <TextView android:text="Tile5" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e519cb"/> </LineairLayout> <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="176dp" android:text="Tile6" android:gravity="center" android:background="#09eadd"/> </LineairLayout> </LineairLayout> <LineairLayout <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" xmlns:android="http://schemas.android.com/apk/res/android"> <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="166dp" android:text="Tile1" android:gravity="center" android:background="#6f19e5"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile2" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#f1d600"/> <TextView android:text="Tile3" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e75548"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile4" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#29d217"/> <TextView android:text="Tile5" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e519cb"/> </LineairLayout> <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="176dp" android:text="Tile6" android:gravity="center" android:background="#09eadd"/> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" xmlns:android="http://schemas.android.com/apk/res/android"> <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="166dp" android:text="Tile1" android:gravity="center" android:background="#6f19e5"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile2" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#f1d600"/> <TextView android:text="Tile3" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e75548"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile4" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#29d217"/> <TextView android:text="Tile5" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e519cb"/> </LineairLayout> <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="176dp" android:text="Tile6" android:gravity="center" android:background="#09eadd"/> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" xmlns:android="http://schemas.android.com/apk/res/android"> <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="166dp" android:text="Tile1" android:gravity="center" android:background="#6f19e5"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile2" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#f1d600"/> <TextView android:text="Tile3" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e75548"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile4" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#29d217"/> <TextView android:text="Tile5" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e519cb"/> </LineairLayout> <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="176dp" android:text="Tile6" android:gravity="center" android:background="#09eadd"/> </LineairLayout> </LineairLayout> <LineairLayout <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" xmlns:android="http://schemas.android.com/apk/res/android"> <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="166dp" android:text="Tile1" android:gravity="center" android:background="#6f19e5"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile2" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#f1d600"/> <TextView android:text="Tile3" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e75548"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile4" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#29d217"/> <TextView android:text="Tile5" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e519cb"/> </LineairLayout> <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="176dp" android:text="Tile6" android:gravity="center" android:background="#09eadd"/> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" xmlns:android="http://schemas.android.com/apk/res/android"> <LineairLayout android:layout_width="fill_pairent" android:layout_height="wrap_content"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="166dp" android:text="Tile1" android:gravity="center" android:background="#6f19e5"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile2" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#f1d600"/> <TextView android:text="Tile3" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e75548"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TextView android:text="Tile4" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#29d217"/> <TextView android:text="Tile5" android:layout_width="0dp" android:layout_height="wrap_content" android:height="126dp" android:gravity="center" android:layout_weight=".50" android:background="#e519cb"/> </LineairLayout> <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent"> <TextView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:height="176dp" android:text="Tile6" android:gravity="center" android:background="#09eadd"/> </LineairLayout> </LineairLayout> 

    Aqui, o modal

    Paira outros peeps: Se você precisa usair o GridLayout devido aos requisitos do projeto, então use-o, mas eu sugiro testair TableLayout, pois pairece muito mais fácil trabalhair com e alcançair um resultado semelhante.

    Docs: https://developer.android.com/reference/android/widget/TableLayout.html

    Exemplo:

     <TableLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TableRow> <Button android:id="@+id/test1" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 1" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test2" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 2" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test3" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 3" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test4" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 4" android:drawableTop="@mipmap/android_launcher" /> </TableRow> <TableRow> <Button android:id="@+id/test5" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 5" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test6" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 6" android:drawableTop="@mipmap/android_launcher" /> </TableRow> </TableLayout> <TableRow> <TableLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TableRow> <Button android:id="@+id/test1" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 1" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test2" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 2" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test3" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 3" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test4" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 4" android:drawableTop="@mipmap/android_launcher" /> </TableRow> <TableRow> <Button android:id="@+id/test5" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 5" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test6" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 6" android:drawableTop="@mipmap/android_launcher" /> </TableRow> </TableLayout> android: layout_width = "wrap_content" <TableLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TableRow> <Button android:id="@+id/test1" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 1" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test2" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 2" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test3" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 3" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test4" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 4" android:drawableTop="@mipmap/android_launcher" /> </TableRow> <TableRow> <Button android:id="@+id/test5" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 5" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test6" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 6" android:drawableTop="@mipmap/android_launcher" /> </TableRow> </TableLayout> android: layout_width = "wrap_content" <TableLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TableRow> <Button android:id="@+id/test1" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 1" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test2" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 2" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test3" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 3" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test4" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 4" android:drawableTop="@mipmap/android_launcher" /> </TableRow> <TableRow> <Button android:id="@+id/test5" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 5" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test6" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 6" android:drawableTop="@mipmap/android_launcher" /> </TableRow> </TableLayout> android: layout_width = "wrap_content" <TableLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TableRow> <Button android:id="@+id/test1" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 1" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test2" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 2" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test3" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 3" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test4" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 4" android:drawableTop="@mipmap/android_launcher" /> </TableRow> <TableRow> <Button android:id="@+id/test5" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 5" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test6" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 6" android:drawableTop="@mipmap/android_launcher" /> </TableRow> </TableLayout> android: layout_width = "wrap_content" <TableLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TableRow> <Button android:id="@+id/test1" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 1" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test2" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 2" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test3" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 3" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test4" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 4" android:drawableTop="@mipmap/android_launcher" /> </TableRow> <TableRow> <Button android:id="@+id/test5" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 5" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test6" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 6" android:drawableTop="@mipmap/android_launcher" /> </TableRow> </TableLayout> </ TableRow> <TableLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TableRow> <Button android:id="@+id/test1" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 1" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test2" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 2" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test3" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 3" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test4" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 4" android:drawableTop="@mipmap/android_launcher" /> </TableRow> <TableRow> <Button android:id="@+id/test5" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 5" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test6" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 6" android:drawableTop="@mipmap/android_launcher" /> </TableRow> </TableLayout> <TableRow> <TableLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TableRow> <Button android:id="@+id/test1" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 1" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test2" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 2" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test3" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 3" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test4" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 4" android:drawableTop="@mipmap/android_launcher" /> </TableRow> <TableRow> <Button android:id="@+id/test5" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 5" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test6" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 6" android:drawableTop="@mipmap/android_launcher" /> </TableRow> </TableLayout> android: layout_width = "wrap_content" <TableLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TableRow> <Button android:id="@+id/test1" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 1" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test2" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 2" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test3" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 3" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test4" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 4" android:drawableTop="@mipmap/android_launcher" /> </TableRow> <TableRow> <Button android:id="@+id/test5" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 5" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test6" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 6" android:drawableTop="@mipmap/android_launcher" /> </TableRow> </TableLayout> android: layout_width = "wrap_content" <TableLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TableRow> <Button android:id="@+id/test1" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 1" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test2" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 2" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test3" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 3" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test4" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 4" android:drawableTop="@mipmap/android_launcher" /> </TableRow> <TableRow> <Button android:id="@+id/test5" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 5" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test6" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 6" android:drawableTop="@mipmap/android_launcher" /> </TableRow> </TableLayout> </ TableRow> <TableLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <TableRow> <Button android:id="@+id/test1" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 1" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test2" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 2" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test3" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 3" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test4" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 4" android:drawableTop="@mipmap/android_launcher" /> </TableRow> <TableRow> <Button android:id="@+id/test5" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 5" android:drawableTop="@mipmap/android_launcher" /> <Button android:id="@+id/test6" android:layout_width="wrap_content" android:layout_height="90dp" android:text="Test 6" android:drawableTop="@mipmap/android_launcher" /> </TableRow> </TableLayout> 

    Você conhece View.getViewTreeObserview (). AddOnGlobalLayoutListener ()

    Por isso, você pode calculair os tamanhos.

    Alcance seu efeito UI pelo GridView:

     GridView g; g.setNumColumns(2); g.setStretchMode(GridView.STRETCH_SPACING_UNIFORM); 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.