Add the following declarations in the Class_Globals subroutine:
Private screensize As Double = GetDeviceLayoutValues.ApproximateScreenSize
Private devwidth As Int
Private devheight As Int
Private cellwidth As Int
Private cellheight As Int
Add the following code to the B4XPage_Created subroutine:
Dim screensize As Double = GetDeviceLayoutValues.ApproximateScreenSize
Dim devwidth As Int = GetDeviceLayoutValues.Width/2
Dim devheight As Int = (GetDeviceLayoutValues.height/2) - 40dip
If screensize > 8 Then
Dim devwidth As Int = GetDeviceLayoutValues.Width
Dim devheight As Int = GetDeviceLayoutValues.height - 80dip
cellwidth = DipToCurrent(devwidth/9)
cellheight = DipToCurrent(devheight/11.5)
Else
cellwidth = DipToCurrent(devwidth/9)
cellheight = DipToCurrent(devheight/13.5)
End If
Log("devwidth: " & devwidth)
Log("devheight: " & devheight)
Log("cellwidth: " & cellwidth)
Log("cellheight: " & cellheight)
If the dividers (9, 11.5 and 13.5) are not good for your device you can change them.
These adjustments were tested on a Samsung Galaxy Tab E tablet with a 9.6 inch screen.
And now we go over the code and change some lines.
Before deleting the old lines you might want to put them in comments!
In B4XPage_Created:
If screensize > 8 Then
cnv.DrawText(strlet,10dip+(c*cellwidth)-20dip,10dip+(8.5*cellheight),tfont,20,Colors.Gray,"LEFT")
Else
cnv.DrawText(strlet,10dip+(c*cellwidth)-5dip,10dip+(9*cellheight),tfont,20,Colors.Gray,"LEFT")
End If