Ziem
Ziem

Reputation: 6697

How to create NxN non scrollable grid?

How can I create NxN grid which automatically scale its items to fit entire screen? I need something similar to GridView but without scrolling. I want to have all items visible and fit to screen dimensions.

Upvotes: 0

Views: 428

Answers (1)

android developer
android developer

Reputation: 116000

Well you can get the size that the gridView can fit to, and then set each of the gridView's views size according to it.

This way, there will not have to be a scrolling at all.

So, for example, if you need an NxN grid and you have 100Nx100N pixels available, for each item give 100x100 pixels.

Of course, you might want to add some padding or separators between them, but that's the basic idea.

In order to get the gridView's size (so that you can set the size of each of its views), you can use this sample code I've made, which works on any type of view.

Upvotes: 1

Related Questions