android GridLayout divider row -
i'm trying implement tabular layout has header , bunch of rows underneath it. i've chosen gridlayout (android.support.v7.widget.gridlayout) there's requirements elements span multiple columns (but of no concern question).
my header cells each contain linearlayout bunch of textviews, they're dynamically filled in code,for sake of example, have @ image below. second row should contain divider simple view, should span header columns (3).
the problem width of divider - if choose match_parent, push gridlayout fill whole remaining space right. grid needs wrap content , center horizontally. seems me there's conflict between grid's layout (wrap_content) , divider's layout (match_parent).
how can fix width of divider without hardcoding it?
http://i61.tinypic.com/2415eg5.png
in red, linearlayouts (header), green, gridlayout itself, thin blue line @ bottom divider.
thanks, mo
solution (as provided below): had set column weight divider 1, without specifying width (actually setting zero). because of specific requirement handle of these in code, solution manually instantiate gridlayout.layoutparams class , use
columnspec = gridlayout.invokespec(row_index, num_spanned_cols, weight)
hope helps others in future.
if set width 0dp give android:layout_weight="1"
(you give weight want) should fill available space , not push bounds if understand asking correctly
Comments
Post a Comment