GridView, GridLayout or TableLayout?

10,307

Solution 1

GridView is scrollable. it would only make sense to use GridView if you load all of the buttons at once and drop the previous and next buttons.

GridLayout is the way to go.

Solution 2

Personally I would think the best way to do this is to create a Relative Layout in code. Get the screen width and height. divide width by 4 divide height by 2 then call

    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(args to make fit screen and be in order);
    myRelativeLayout.addView(lp);

and set the images in the order you want. to get the gaps use images that have alpha so the edges make the gap.

then call

    invalidate()

but that is just me. :)

check out some other places like How to lay out Views in RelativeLayout programmatically?

Share:
10,307
Carlos Pereira
Author by

Carlos Pereira

Updated on July 29, 2022

Comments

  • Carlos Pereira
    Carlos Pereira almost 2 years

    I need to create some screens similar to this one:

    enter image description here

    Also, if the user wants to show more buttons per screen, it would be something like this:

    enter image description here

    Today I am using LinearLayouts to do this.

    I would like to know which option is the best to develop a design like the above.

    1. User must not swype up or down to see the rest of buttons, the rest of buttons will be shown through the navigation buttons (don't worry, I will use a Viewflipper to do this)

    2. Buttons must use all the screen and must have the same size. They must resize itself if images are big to fit the screen size

    3. Lightweight. Low consumption of memory

    4. Buttons when clicked may open new grids

    What is the best option for this? GridView, GridLayout or TableLayout?

    Thank you in advance!

  • Sarvesh
    Sarvesh almost 11 years
    Any idea how did you decide on that? I need an example. Also how did the resize work?