Probably that is really a night question!
Probably i should just take in account the relationship: 92dpi (laptop) : 160dip (android - for standard variant)
Private db As BitmapDrawable
db.Initialize(LoadBitmap(File.DirAssets, "rows.png"))
Activity.Background = db
Scale.SetReferenceLayout(1024, 600, 1, True, False)
Scale.ScaleAll(Activity, True)
btnAppExit.Left = 50%x - btnAppExit.Width / 2
btnAppExit.Top = 100%y - btnAppExit.Height
Private Sub WriteText
Private cnv As Canvas
cnv.Initialize(Activity)
Private X,Y As Float
Private RowHeight As Float
RowHeight = 60dip
X = 5dip
Y = RowHeight - 1dip
cnv.DrawText("First text", X, Y, Typeface.DEFAULT, 22 * Scale.GetScaleTxt, Colors.Blue, "LEFT")
For r = 1 To 9
Y = Y + RowHeight
cnv.DrawText("Other " & r, X, Y, Typeface.DEFAULT, 22 * Scale.GetScaleTxt, Colors.Blue, "LEFT")
Next
End Sub
The second should be that Canvas functions probably internally uses Dip
Uhm... I'm not so sure, since in the Beginner's Guide all the examples use dips!
Private Sub WriteText
Private X,Y As Float
Private RowHeight, TextSize As Float
Private lv As LayoutValues
' RowHeight = 60dip
RowHeight = Activity.Height / 10
X = 5dip
lv = GetDeviceLayoutValues
TextSize = RowHeight / lv.Scale * 0.8
Y = RowHeight * 0.75
' cnv.DrawText("First text", X, Y, Typeface.DEFAULT, 22 * Scale.GetScaleTxt, Colors.Blue, "LEFT")
cnv.DrawText("First text", X, Y, Typeface.DEFAULT, TextSize, Colors.Blue, "LEFT")
For r = 1 To 9
Y = Y + RowHeight
' cnv.DrawText("Other " & r, X, Y, Typeface.DEFAULT, 22 * Scale.GetScaleTxt, Colors.Blue, "LEFT")
cnv.DrawText("Other " & r, X, Y, Typeface.DEFAULT, TextSize, Colors.Blue, "LEFT")
Next
End Sub
I would do it that way:
This works on different screen sizes.
The RowHeight is defined by Activity.Height / NumberOfLines
And the TextSize is calculated in function of the RowHeight.
You can play with the two factors 0.8 and 0.75
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?