Dim x_padding as int = 4dip
Dim y_padding as int=2dip
Dim margin as int = page_width/20
Dim NUM_ROWS as int =10
Dim NUM_COLS as int=4
Dim Y_TOP as int = page_height/10
Dim CELL_WIDTH as Int = (page_width - 2*margin)/NUM_COLS 'or whatever you choose
Dim CELL_WIDTH_ACTIVE as int = CELL_WIDTH - 2*x_padding
Dim CELL_HEIGHT as int = ...
'Here you can adapt your font size so that all texts can fit in the cells, or adapt the texts (trubcate, ...) for a given font size
'...
'...
'...
Dim myCanvas as canvas
myCanvas.initialize(...)
Dim myTextentries(NUM_ROWS*NUM_COLS) as string=Array as String("First text","Second text",......)
Dim myFontSize as int = 25
for k=0 to num_entries-1
Dim myText as string = myTextEntries(k)
for mySize=1 to 100
Dim ww as int = myCanvas.MeasureStringWidth(myText,myTypeface,mySize)
if ww>=CELL_WIDTH_ACTIVE then
'Here you can choose to adapt the font size, truncate the text, .....
end if
'Can do something similar with height, if you decide to draw multiline.....
next
next
for y=0 to NUM_ROWS-1
for x=0 to NUM_COLS-1
myText=myTextEntries(y*NUM_COLS+x) 'or whatever order they have
'Texts aligned to the left for each cell
'myCanvas.DrawText( myText, LEFT_MARGIN + x*CELL_WIDTH + x_padding, Y_TOP+y*CELL_HEIGHT+y_padding, Typeface.DEFAULT, myFontSize, myTextColor, "LEFT")
'Horizontally center aligned texts in each cell
myCanvas.DrawText( myText, LEFT_MARGIN + x*CELL_WIDTH + CELL_WIDTH/2, Y_TOP+y*CELL_HEIGHT+y_padding, Typeface.DEFAULT, myFontSize, myTextColor, "CENTER")
next
next