Create buttons in a grid layout

0

I would like to know how to do an activity as a grid menu ... What kind of layout is most advisable? A relative , linear, grid or table ?

Example of what I need:

No need for banners, just the menu.

    
asked by anonymous 28.08.2017 / 15:12

1 answer

1

Grid layout is the GridLayout

p>

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>

Result :

So, just adjust the settings due to centralization of views , use of ImaveView , etc.

    
28.08.2017 / 16:10