Android Question Screen width & height ?

jinyistudio

Well-Known Member
Licensed User
Longtime 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 ?
 

Mark Read

Well-Known Member
Licensed User
Longtime User
Activity.Width or Activity.Height
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime 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
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime 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

  • Noname.png
    Noname.png
    41.7 KB · Views: 305
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime 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
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime 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...
 
Upvote 0
Top