Android Question Screen width & height ?

jinyistudio

Active Member
Licensed User
Hi

I want to put a panel(fixed size) into the central of screen but i don't know get current screen width & height. Could you tell me how to do it ?
 

mark35at

Well-Known Member
Licensed User
Activity.Width or Activity.Height
 

jinyistudio

Active Member
Licensed User
Activity.Width or Activity.Height
My current code but the result of n1,n2 are zero

Sub ShowPopupMenu(bShow As Boolean)
Dim n1,n2 As Int

n1 = (Activity.Width -Panel1.Width) Mod 2
n2 = (Activity.Height-Panel1.Height) Mod 2


Panel1.Left = n1
Panel1.Top = n2

Panel1.Visible = bShow
End Sub
 

jinyistudio

Active Member
Licensed User
My current code but the result of n1,n2 are zero

Sub ShowPopupMenu(bShow As Boolean)
Dim n1,n2 As Int

n1 = (Activity.Width -Panel1.Width) Mod 2
n2 = (Activity.Height-Panel1.Height) Mod 2


Panel1.Left = n1
Panel1.Top = n2

Panel1.Visible = bShow
End Sub
 

Attachments

jinyistudio

Active Member
Licensed User
Using following is OK, Thank's :(

Private lv As LayoutValues

lv = Activity.LoadLayout("bluelt_main")


Sub ShowPopupMenu(bShow As Boolean)
Dim n1,n2 As Int

n1 = (lv.Width -Panel1.Width) / 2
n2 = (lv.Height-Panel1.Height) / 2

Panel1.Left = n1
Panel1.Top = n2

Panel1.Visible = bShow
End Sub
 

eurojam

Well-Known Member
Licensed User
you have to assign your panel to the activity or any parent view before you can calculate any values with it. that the reason for the error you got. While loading the layout, the panel is assigned and you will get your values...
 
Top