If LayoutWidth = 1280 Then
LeftMargin = C1.Left
Else
LeftMargin = CardWidth
End If
OffsetVertical = (Activity.Height - 20 - CardHeight) / 12
CardTop = Activity.Height - CardHeight
' Calculate how much of each of the player's 13 cards will fit onscreen:
i = Activity.Width - LeftMargin * 2 - CardWidth ' last card is shown full
Offset = i / 12
' If offset is not an even number, a gap will be left on the right
' end of the cards, so divide that gap between the left and right:
j = 12 * Offset + LeftMargin * 2 + CardWidth
LeftMargin = LeftMargin + (Activity.Width - j) / 2
scrnCenter = Activity.Width / 2
labelCardsOut.Left = scrnCenter - labelCardsOut.Width/2
ExplainPanel.Left = scrnCenter - ExplainPanel.Width/2
explainRight = ExplainPanel.Left + ExplainPanel.Width
i = labelWinner2.Left - labelWinner1.Left
labelWinner1.Left = scrnCenter - labelWinner1.Width/2
labelWinner2.Left = scrnCenter - labelWinner2.Width/2 + i
labelHiGameScore.Left = scrnCenter - labelHiGameScore.Width/2
labelHiGameScore.Top = Activity.Height - labelHiGameScore.Height * 2
labelHiGameScore.Visible = False
If LayoutWidth <> Activity.Width Then
AdjustLeft = (LayoutWidth - Activity.Width) / 2
btnOptions.Left = btnOptions.Left - AdjustLeft * 2 ' Get out of the way of East's cards
btnHelp.Left = btnHelp.Left - AdjustLeft * 2
btnHint.Left = btnHint.Left - AdjustLeft ' re-center from here down
btnOkay.Left = btnOkay.Left - AdjustLeft
OptionsPanel.Left = OptionsPanel.Left - AdjustLeft
If OptionsPanel.Left < 0 Then OptionsPanel.Left = 0
PlayerNums.Left = PlayerNums.Left - AdjustLeft
ScorePanel.Left = ScorePanel.Left - AdjustLeft
panelCards.Left = panelCards.Left - AdjustLeft
panelKeyboard.Left = panelKeyboard.Left - AdjustLeft
labelDetail0.Left = labelDetail0.Left - AdjustLeft ' These are the score detail labels
labelDetail2.Left = labelDetail2.Left - AdjustLeft
' LabelDetail1: center between CardWidth and explainPanel.Left
labelDetail1.Left = CardWidth + (ExplainPanel.Left - CardWidth)/2 - labelDetail1.Width/2
' LabelDetail3: center between ExplainPanel and cards
cardsLeft = Activity.Width - CardWidth 'This line and the one above must come before the next 2.
labelDetail3.Left = ExplainRight + (cardsLeft - ExplainRight)/2 - labelDetail3.Width/2
If labelDetail3.Left > explainRight Then labelDetail3.Left = explainRight
End If
If panelCards.Left + panelCards.Width > Activity.Width - CardWidth Then
panelCards.Left = Activity.Width - CardWidth - panelCards.Width
End If
' WebView Help file viewer:
If DeviceType = Dim800x480x240 Then
HelpFile = "spades_help_small.htm"
Else
HelpFile = "spades_help.htm"
End If
panelWebView.SetLayout(0, 0, Activity.Width, Activity.Height)
ViewHelp.SetLayout(0, btnSearchAgain.Height + 2, Activity.Width, Activity.Height - btnSearchAgain.Height - 2)
ViewHelp.LoadURL("file:///android_asset/" & HelpFile)
btnWebViewExit.Left = Activity.Width - btnWebViewExit.Width - 1
btnWebViewBack.Left = btnWebViewExit.Left - btnWebViewBack.Width - 5
panelWebView.Visible = False
' Score panel:
labelNameS.Left = scrnCenter - labelNameS.Width/2
labelNameN.Left = scrnCenter - labelNameN.Width/2
labelNameW.Left = CardWidth
labelNameE.Left = Activity.Width - CardWidth - labelNameE.Width
labelNameS.Top = Activity.Height - CardHeight - labelNameS.Height
labelNameN.Top = CardHeight
labelNameW.Top = (Activity.Height - labelNameW.Height)/2
labelNameE.Top = (Activity.Height - labelNameE.Height)/2
If DeviceType = Dim800x480x240 Then labelNameS.Visible = False ' no room
labelTrickNum.Left = btnOptions.left + 5
labelTime.Left = labelTrickNum.Left
labelBattery.Left = labelTrickNum.Left
' Adjustment for tablets whose menu bar is at the bottom of the screen in landscape mode:
If LayoutHeight <> Activity.Height Then
AdjustUp = (LayoutHeight - Activity.Height) / 2 ' This could be negative for a taller screen, like a 4:3 aspect ratio
ExplainPanel.Top = ExplainPanel.Top - AdjustUp
ScorePanel.Top = ScorePanel.Top - AdjustUp
PlayerNums.Top = PlayerNums.Top - AdjustUp
labelDetail1.Top = labelDetail1.Top - AdjustUp
labelDetail3.Top = labelDetail3.Top - AdjustUp
panelCards.Top = panelCards.Top - AdjustUp
End If
labelDetail0.Top = Activity.Height - CardHeight - labelDetail0.Height
panelKeyboard.Top = Activity.Height - panelKeyboard.Height - 1
i = labelWinner2.Top - labelWinner1.Top
labelWinner1.Top = CardHeight + (ScorePanel.Top - CardHeight - labelWinner1.Height) /2
labelWinner2.Top = labelWinner1.Top + i
DoEvents
labelReplayFile.Left = scrnCenter - labelReplayFile.Width/2
labelReplayFile.Top = ExplainPanel.Top + ExplainPanel.Height
btnHint.Top = labelReplayFile.Top + labelReplayFile.Height
btnOkay.Top = btnHint.Top
btnGeneral.Top = btnHint.Top
btnGeneral.left = (Activity.Width - btnGeneral.Width) / 2
labelCardsOut.Top = ExplainPanel.Top - labelCardsOut.Height
If labelCardsOut.Top < labelNameN.Top + labelNameN.Height Then
labelCardsOut.Top = labelNameN.Top + labelNameN.Height + 5
End If
btnOkayTop = btnOkay.Top
btnOkayLeft = btnOkay.Left
btnHelpTop = btnHelp.Top
btnHelpLeft = btnHelp.Left
If panelCards.Top + panelCards.Height > btnOkay.Top Then
panelCards.Top = btnOkay.Top - panelCards.Height - 5
End If