jakehschwartz
jakehschwartz

Reputation: 1005

Two column table on android

Hey everyone. I'm not big into UI programming so this may be an easy thing I overlooked. I am trying have a screen that shows 8 TextView in a 2 column x 4 row table. And, of course, I want the TextViews, that might have different lengths, to be centered. I tried this in a table layout, for obvious reasons but I feel like this is not the way to do it because it doesn't have much control where I put everything once it is in a row. Should I be using a different combinations of layouts or is there something I overlooked.

I can post my xml file if you really need but this is really more of a concept question than a specific one.

Thanks, Jake

Upvotes: 1

Views: 977

Answers (2)

Rich Schuler
Rich Schuler

Reputation: 41972

Check out apps-for-android's GridLayout. You may have to modify it a bit to get it to do exactly what you want, however, it's probably a good starting point.

Upvotes: 1

QRohlf
QRohlf

Reputation: 2853

Can you explain why a table layout didn't work in more detail? If you're just trying to center the contents of the cells, you can set the android:gravity attribute in the table layout to "center"

EDIT: You can set the spacing between items using the android:padding attribute (Documentation). There are a number of other attributes in that link you can use to modify the way your table is laid out, as well as table-specific attributes at this link.

Upvotes: 1

Related Questions