jeudi 14 mai 2015

android GridLayout divider row

I'm trying to implement a tabular layout that has a header and a bunch of rows underneath it. I've chosen the GridLayout (android.support.v7.widget.GridLayout) as there's some requirements for some elements to span multiple columns (but those are of no concern to the question).

My header cells each contain a LinearLayout with a bunch of TextViews, they're dynamically filled in code,for the sake of example, have a look at the image below. The second row should contain the divider which is a simple view, that should span my header columns (3).

The problem is the width of the divider - if I choose MATCH_PARENT, it will push the GridLayout to fill the whole remaining space to the right. The grid needs to wrap the content and center itself horizontally. It seems to me there's a conflict between the grid's layout (WRAP_CONTENT) and the divider's layout (MATCH_PARENT).

How can I fix the width of the divider without hardcoding it?

http://ift.tt/1RKo1pA

In red, my LinearLayouts (header), green, the GridLayout itself, the thin blue line at the bottom is the divider.

Thanks, MO

Aucun commentaire:

Enregistrer un commentaire