hello everyone, I have a problem, I am making a program that EditText through the push of a button allows the display of text in an image, use the canvas for this project, my problem is that if I use for example the samsung galaxy s2 with resolution of 320x480, the program sees perfectly, but if you use a phone with a resolution of 320x240 the lyrics are not in their respective positions as in samsung galaxy s2, how do I display the same location but with different phones at different resolutions on canvas?
place my code, and two photo example, the number 1 and with 320x240 resolution while the number 2 and with a resolution of 320x480
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim b As Bitmap
Dim brect As Rect
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim c As Canvas
Dim i As ImageView
Dim tf As Typeface
Dim t As String
Dim p As Phone
Dim imglogo As ImageView
Dim txtazienda As EditText
Dim txtdescrizione As EditText
Dim txtnome As EditText
Dim txtluogo As EditText
Dim txtvia As EditText
Dim txtcap As EditText
Dim txtemail As EditText
Dim txttelefono As EditText
Dim btn1 As Button
Dim Panel1 As Panel
Dim txtnumero As EditText
Dim Panel2 As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("biglietti")
p.SetScreenOrientation(0)
imglogo.SetLayout(0%x,0%y,100%x,100%y)
Panel1.SetLayout(0%x,0%y,100%x,100%y)
Panel2.SetLayout(0%x,0%y,100%x,100%y)
txtnome.SetLayout(0%x,2%y,40%x,14%y)
txtazienda.SetLayout(42%x,2%y,58%x,14%y)
txtdescrizione.SetLayout(0%x,16%y,100%x,20%y)
txtvia.SetLayout(0%x,37%y,65%x,14%y)
txtnumero.SetLayout(67%x,37%y,15%x,14%y)
txtcap.SetLayout(85%x,37%y,15%x,14%y)
txtluogo.SetLayout(0%x,52%y,55%x,14%y)
txttelefono.SetLayout(57%x,52%y,43%x,14%y)
txtemail.SetLayout(0%x,67%y,50%x,14%y)
btn1.SetLayout(52%x,67%y,48%x,14%y)
Panel1.SendToBack
Panel2.SendToBack
txtnome.Visible=True
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub imglogo_Click
End Sub
Sub btn1_Click
i.Initialize("")
imglogo.Bitmap = LoadBitmap(File.DirAssets, "test.jpg")
b.Initialize(File.DirAssets, "test.jpg")
brect.Initialize(0,0,imglogo.Width, imglogo.Height)
c.Initialize(imglogo)
c.DrawColor(Colors.White)
c.DrawBitmap(b, Null, brect)
c.DrawText(txtnome.Text, 10dip,imglogo.Height-360dip,tf.CreateNew(Typeface.SERIF, Typeface.STYLE_BOLD), 20, Colors.Black , "LEFT")
c.DrawText(txtazienda.Text, 10,imglogo.Height-310,tf.CreateNew(Typeface.SERIF, Typeface.STYLE_BOLD), 35, Colors.Blue , "LEFT")
c.DrawText(txtdescrizione.Text, 10,imglogo.Height-280,tf.CreateNew(Typeface.SERIF, Typeface.STYLE_BOLD), 15, Colors.Black, "LEFT")
c.DrawText(txtvia.Text, 10,imglogo.Height-200,tf.CreateNew(Typeface.SERIF, Typeface.STYLE_BOLD), 18, Colors.Black , "LEFT")
c.DrawText("N°" &" " & txtnumero.Text & " - " , 10,imglogo.Height-170,tf.CreateNew(Typeface.SERIF, Typeface.STYLE_BOLD), 18, Colors.Black , "LEFT")
c.DrawText("Cap:" &" " & txtcap.Text, 145,imglogo.Height-170,tf.CreateNew(Typeface.SERIF, Typeface.STYLE_BOLD), 18, Colors.Black, "LEFT")
c.DrawText(txtluogo.Text, 320,imglogo.Height-170,tf.CreateNew(Typeface.SERIF, Typeface.STYLE_BOLD), 18, Colors.Black , "LEFT")
c.DrawText("Email:" &" " & txtemail.Text, 60,imglogo.Height-120,tf.CreateNew(Typeface.SERIF, Typeface.STYLE_BOLD), 18, Colors.Magenta, "LEFT")
c.DrawText("Telefono:" &" " &txttelefono.Text, 220,imglogo.Height-80,tf.CreateNew(Typeface.SERIF, Typeface.STYLE_BOLD), 18, Colors.Green , "LEFT")
i.Invalidate
txtnome.Visible=False
txtazienda.Visible=False
txtdescrizione.Visible=False
txtvia.Visible=False
txtcap.Visible=False
txtluogo.Visible=False
txtemail.Visible=False
txttelefono.Visible=False
txtnumero.Visible=False
btn1.Visible=False
Panel1.Visible = False
Panel2.Visible=True
imglogo.BringToFront
End Sub