Instead of thinking why don't you read what I posted and also check the documentation.I think Layoutvalues just shows the screen dimensions of your device
Dim lv As LayoutValues
lv = Activity.LoadLayout("somelayout")
I feel pretty stupid, cannot get my head around it. You say you create %x/%y values for each variant and each screen? But when I look at below code you don't seem to use all these values. You say in portrait mode Height < 700, so which values are you using then? The ones from the 320x480 variant or the 480x800 variant? I mean, the %x or %y differ for these is.
What I mean is, if you create the x% and y% values like in the spreadsheet, for which variants do you do this? You indicated you use three: 320x480, 480x800 and 800x1200. So if you do <700 in code which calculated %x and %y do you use from the spreadsheet? The ones for 320x480 or the ones for 480x800? Two variants could mean different button positions for example, so different %x/%y.
BTW, i'm now using a check for which variant is used, as indicated by agraham. So if a variant exists I don't resize anything because I want to use exact that one. That always gives me freedom to do one special device.
Sub FitPnl(pnl As Panel)
pnl.Top=0
pnl.Left=0
pnl.Width=100%x
pnl.Height=100%y
End Sub
Sub FitLbl(lbl As Label)
Dim percLeft,percTop,percWidth,percHeight As Float
percLeft=lbl.Left/pnlW
lbl.Left=pnlW*percLeft
percTop=lbl.Top/pnlH
lbl.Top=pnlH*percTop
percWidth=lbl.Width/pnlW
lbl.Width=pnlW*percWidth
percHeight=lbl.Height/pnlH
lbl.Height=pnlH*percHeight
End Sub
'Activity module
Sub Process_Globals
End Sub
Sub Globals
Dim lblTest As Label
Dim pnlContainer As Panel
'panel
Dim pnlW,pnlH As Int
'label
Dim percLeft,percTop,percWidth,percHeight As Float
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")
'panel dimensions from designer:
pnlW=pnlContainer.Width
pnlH=pnlContainer.Height
CalcLbl(lblTest)'calculate the Label in % of the designed panel
FitPnl(pnlContainer)'new dimention of the panel to fit the device
AdaptLbl(lblTest)'new dimension of the Label according to the new panel's dimentions
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub CalcLbl(lbl As Label)
'proportionally in % of the designed original panel
percLeft=lbl.Left/pnlW
percTop=lbl.Top/pnlH
percWidth=lbl.Width/pnlW
percHeight=lbl.Height/pnlH
End Sub
Sub FitPnl(pnl As Panel)
'fits panel to device
pnl.Top=0
pnl.Left=0
pnl.Width=100%x
pnl.Height=100%y
End Sub
Sub AdaptLbl(lbl As Label)
'adapt the Label to the new dimention sof the panel
lbl.Left=pnlContainer.Width*percLeft
lbl.Top=pnlContainer.Height*percTop
lbl.Width=pnlContainer.Width*percWidth
lbl.Height=pnlContainer.Height*percHeight
End Sub
I guess that's the problem, no universal rules
Do you know if you can check in code which variant the app. picked? I know we can check the device scale etc. but say for example I have three variants: 320x480, 480x800 and 800x1200 and I run this on my Galaxy Nexus. It would be nice to be able to check in code which variant it picks. I don't want to go into separate files per variant.
In above sample my Galaxy Nexus still picks 320x480.
Is it better to focus on different scales instead of resolution?
Sub Get_Screen_Resolution
Main.pScreenWidth=GetDeviceLayoutValues.Width
Main.pScreenHeight=GetDeviceLayoutValues.Height
Main.pScale=GetDeviceLayoutValues.Scale
If Main.pScale= 0.75 Then
Main.pDPI="120"
End If
If Main.pScale= 1 Then
Main.pDPI="160"
End If
If Main.pScale= 1.5 Then
Main.pDPI="240"
End If
If Main.pScale=2 Then
Main.pDPI="320"
End If
End Sub
LoadLayout (Layout As String) As LayoutValues
Loads a layout file (.bal).
Returns the LayoutValues of the actual layout variant that was loaded.
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?