Create buttons in a grid layout

Asked

Viewed 521 times

0

I would like to know how it is possible to make a Activity as a grid menu... Which type of layout is most advisable? A relative, linear, grid or table?

Example of what I need:

inserir a descrição da imagem aqui

No need for banners, just the menu.

1 answer

1


The layout suitable for bars is the Gridlayout

See an example grid with 2 columns and 2 Lines:

<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/GridLayout1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:columnCount="2"
    android:rowCount="2"
    android:orientation="horizontal"
    tools:context=".GridXMLActivity" >
    <Button
        android:id="@+id/button1"
        android:layout_gravity="left|top"
        android:text="Button" />

    <Button
        android:id="@+id/button2"
        android:layout_gravity="left|top"
        android:text="Button" />

    <Button
        android:id="@+id/button3"
        android:layout_gravity="left|top"
        android:text="Button" />

    <Button
        android:id="@+id/button4"
        android:layout_gravity="left|top"
        android:text="Button" />   
</GridLayout>

Upshot:

inserir a descrição da imagem aqui

Therefore, simply adjust the appropriate settings such as centralization of views, use of ImaveView, etc..

  • thanks for the lighting ^^

  • @Renatopedrozo if the answer helped you solving your problem and want to validate it, feel free =D

Browser other questions tagged

You are not signed in. Login or sign up in order to post.