Italian Adattabilità dell'interfaccia

sirjo66

Well-Known Member
Licensed User
Longtime User
Scusa Luciano, ma intendi table.text oppure table.textsize ??

Per sapere la misura in pollici dello schermo puoi fare un calcolo, anche se (secondo me) non esce proprio preciso preciso.

Per scalare le Activity ed adattarle a tutti gli schermi la cosa migliore è usare la classe "Scale" di Klaus, io l'ho provata e mi trovo bene, eccovi qui l'ultima versione

Ciao
Sergio
 

Attachments

  • Scale.bas
    22 KB · Views: 158

udg

Expert
Licensed User
Longtime User
Se può interessare, il seguente codice (di Erel), mostra i valori fisici del device:
B4X:
Sub Activity_Create(FirstTime As Boolean)
If 100%x > 100%y Then Log("Landscape") Else Log("Portrait")
Dim lv AsLayoutValues = GetDeviceLayoutValues
Log(lv & ", size = " & lv.ApproximateScreenSize)
End Sub
 

luciano deri

Active Member
Licensed User
Longtime User
Grazie a tutti ecco la soluzione che sintetizza i vostri suggerimenti
B4X:
Sub DeterminaLayout
Dim lv As LayoutValues
lv = GetDeviceLayoutValues
Dim screensize As Double
screensize = lv.ApproximateScreenSize
Select True
    Case screensize <= 4
            table.TextSize = 10
            table.HeaderHeight = 8%Y
            table.RowHeight = 8%Y

    Case screensize > 4 And screensize <= 7
            table.TextSize = 13
            table.HeaderHeight = 6%Y
            table.RowHeight = 6%Y

    Case screensize > 7 And screensize <= 10
            table.TextSize = 16
            table.HeaderHeight = 4%Y
            table.RowHeight = 4%Y

    Case screensize > 10
            table.TextSize = 19
            table.HeaderHeight = 3%Y
            table.RowHeight = 3%Y          
End Select  
End Sub
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Non era completo, eh, era solo per dire come andrebbe usato.
Nel tuo caso (modificando il tuo codice):
B4X:
Sub DeterminaLayout

Dim lv As LayoutValues
lv = GetDeviceLayoutValues
Dim screensize As Double
screensize = lv.ApproximateScreenSize

Select Case screensize
    Case < 4
            table.TextSize = 10
            table.HeaderHeight = 8%Y
            table.RowHeight = 8%Y

    Case < 7
            table.TextSize = 13
            table.HeaderHeight = 6%Y
            table.RowHeight = 6%Y

    Case  < 10
            table.TextSize = 16
            table.HeaderHeight = 4%Y
            table.RowHeight = 4%Y

    Case > 10 ' andrebbe bene anche Case Else
            table.TextSize = 19
            table.HeaderHeight = 3%Y
            table.RowHeight = 3%Y          
End Select  
End Sub
 

udg

Expert
Licensed User
Longtime User
Mi sa che dipende da quel "Case" che segue il Select

Dovrebbe essere:
Select screensize

udg
 

LucaMs

Expert
Licensed User
Longtime User
Infatti... ha un funzionamento completamente diverso da VB.Net e totalmente illogico.
Questo, ad esempio, funziona:
B4X:
    Dim Screen_Size, Pippo As Int
   
    Screen_Size = 3
    Pippo = 8

    Select True
        Case Screen_Size < 4 AND Pippo > 10
            Log("<4")
        Case Screen_Size < 4 AND Pippo < 10
            Log("cavolata")
    End Select
 

LucaMs

Expert
Licensed User
Longtime User
Ma funziona anche così (senza variabile ma solo col valore esatto, non con i simboli <>...)
B4X:
    Dim Screen_Size As Int
   
    Screen_Size = 3

    Select Case Screen_Size
        Case 4
            Log("4")
        Case 3
            Log("ancora una cavolata")
    End Select
 

luciano deri

Active Member
Licensed User
Longtime User
A questo punto c'è ben poca differenza rispetto all'uso di una lunga serie di IF Else


(uhm... ho il sospetto che siamo leggermente usciti fuori tema, colpa mia, hehehe)
Si il select case funziona a chez, ma nel caso specifico il codice risulta un po' più leggibile rispetto alla catena di if che verrebbe
B4X:
if SceenSize <= 4
....
else
   if SceenSize > 4 and ScreenSize <= 7
       .....
   else
       if screensize ....
       else
          if 'stella sull'albero di natale
          else
          end if
       end if
   end if
end if
 

sirjo66

Well-Known Member
Licensed User
Longtime User
Mi sembra che bisogna scriverlo così:
B4X:
Sub DeterminaLayoutDim lv AsLayoutValues
lv = GetDeviceLayoutValuesDim screensize As Double
screensize = lv.ApproximateScreenSize
Select Case screensize
Case Is < 4
    table.TextSize = 10
    table.HeaderHeight = 8%Y
    table.RowHeight = 8%Y
Case Is < 7
    table.TextSize = 13
    table.HeaderHeight = 6%Y
    table.RowHeight = 6%Y
Case Is < 10
    table.TextSize = 16
    table.HeaderHeight = 4%Y
    table.RowHeight = 4%Y
Case Else
    table.TextSize = 19
    table.HeaderHeight = 3%Y
    table.RowHeight = 3%Y
End Select
End Sub

P.S.: il Case Else sarebbe meglio, perchè nel caso in cui il valore di screenSize è 10, il codice originale (scritto da Luca) non funziona dato che ha solo testato per "minore di 10" o per "maggiore di 10"
 
Top