Italian ScrollView & Designer

luciano deri

Active Member
Licensed User
Longtime User
Salve a Tutti. Ho fatto un bellissimo Layout dal Designer denso di campi. Con display piccoli piuttosto che ridimensionare preferirei uno scroll almeno per la dimensione verticale. Credo che devo aggiungere il componete ScroollView, c'è un modo semplice per aggiungerlo al Layout magari dal Designer? Saluti e Grazie.
 

LucaMs

Expert
Licensed User
Longtime User
Non penso che tu possa risolvere il problema aggiungendo una ScrollView. Penso che dovresti proprio ridimensionare il layout oppure crearne uno molto simile con un diverso variant.

Comunque puoi tentare. Dato che io ho una vecchia versione di b4a non sono certissimo, ma quasi, che con una recente sia possibile fare il copia e incolla delle view, nel Designer; quindi, DOVRESTI selezionare tutte le view, "tagliarle" con CTRL+X, aggiungere un pannello al layout e poi incollare di nuovo le view con CTRL+V. Non è detto che questo funzioni, perché potrebbe spostare i riferimenti delle view (ripeto, io non ho il copia e incolla).

Se funziona, poi dovrai comunque creare la ScrollView nel codice e caricare il pannello creato nel Designer all'interno della ScrollView (più precisamente nel pannello interno della ScrollView). Altrimenti, sempre creando la ScrollView nel codice, carichi il layout nel pannello interno della ScrollView da codice.

Spiegazione contorta ma spero ti sia di aiuto.
 

luciano deri

Active Member
Licensed User
Longtime User
Ok e grazie. La cosa è un pochino più complessa dato che il tutto sta sopra ad un tabhost. La soluzione che ho trovato funziona ma non so se è la migliore.
1 Ho creato un layout con solo panel e scrollview (LyTab1)
2 nel 1 tabhost carico il LyTab1.
3 nello scrollview carico il panel
4 nel panel carico il mio layout (LyTesta)
Di seguito il codice.
B4X:
Activity.LoadLayout("LyMain")
Sub Activity_Create(FirstTime As Boolean)
    THScreenDati.AddTab("Intestazione", "LyTab")
    SVTab.RemoveView
    SVTab.Initialize(1000)
    Activity.AddView(SVTab, 5,230, 99%x, 100%y) 
    PnTab.Initialize("PnTab")
    SVTab.Panel.AddView(PnTab, 0,0, 100%x, 1280)
    PnTab.LoadLayout("LyTesta")
    SVTab.Panel.Height    = 1170
    THScreenDati.AddTab("Dettagli", "LyCorpo")
    THScreenDati.AddTab("Riepilogo", "LyPiede")
End Sub
Il problema è che mentre prima al click delle etichette sul tabhost cambiava il layout, adesso l'etichetta si sposta ma il layout mostrato è sempre il LyTesta. Presumo devo fare qualcosa nel tabchange per modificare dinamicamente il contenuto di Lytab?
 
Last edited:

klaus

Expert
Licensed User
Longtime User
Your code looks strange to me.
You load "LyTab" onto Tab "Intestazione", what do you have in "LyTab" ?
Then you remove SVTab, why ?
Then you add SVTab onto the Activity and not onto a Tab, why ?
Activity.AddView(SVTab, 5,230, 99%x, 100%y)
SVTab.Top is 230, but the Height is 100%y so the bottom of SVTab is below the lower screen edge !?
Then you initialize a Panel and add it onto SVTab.Panel
SVTab.Panel.AddView(PnTab, 0,0, 100%x, 1280)
with a height of 1280, you should use dip values and not absolute pixels.
Then you load "LyTesta" ontp PnTab.
PnTab.LoadLayout("LyTesta")
Then you set SVTab.Panel.Height = 1170
The height is 1170, but PnTab.Height is 1280, why ?
Here too, you should use dip values.

Can you post your project as a zip file so we could have a look at it.
 

luciano deri

Active Member
Licensed User
Longtime User
Sorry Klaus, but not all that i do in b4a is very clear.

You load "LyTab" onto Tab "Intestazione", what do you have in "LyTab" ?
LyTab is a layaout with only scrollview (SVTab)
Then you remove SVTab, why ? This line is removed
Then you add SVTab onto the Activity and not onto a Tab, why ?
I thinked that is the right metod per add SVTab on my layout. How can add SVTab at the Tab?
The scroll begin after label of tabs, so scroller only this part of screen
Activity.AddView(SVTab, 5,230, 99%x, 100%y)
SVTab.Top is 230, but the Height is 100%y so the bottom of SVTab is below the lower screen edge !?

I thinked that is the right metod, and 100% is the total space between top (230) and the botton of screen.
Then you initialize a Panel and add it onto SVTab.Panel
SVTab.Panel.AddView(PnTab, 0,0, 100%x, 1280)
with a height of 1280, you should use dip values and not absolute pixels.
Then you load "LyTesta" ontp PnTab.
PnTab.LoadLayout("LyTesta")
Then you set SVTab.Panel.Height = 1170
The height is 1170, but PnTab.Height is 1280, why ?

1280 is the height of display (10" portrait), 1170 is the height after top scroll view. So if the display is smaller by heigth scrolling is possible show all screen.

Tanks.
 

luciano deri

Active Member
Licensed User
Longtime User
Can you post your project, it would be easier to help you.
How give you the source code in private mode?
I think that the most importa problem is how insert a scrollview in a tab, because there is not a istruction similar THScreenDati.tab.AddView(1,SVTab, 5,230, 99%x, 100%y), where 1 is the number of tab. Add scrollview on activity i think that the scroll is up all tabs.
 
Last edited:

luciano deri

Active Member
Licensed User
Longtime User
pssss buttali i tabhost ;)

(oppure segui questo thread spettacolare)
Buttarlo è dura però quel tutorial pare davvero interessante... ci provo ancora un po' prima di buttare a mare sti tabhost.:mad:

L'alternativa, che per certi versi sarebbe più facile, sarebbe quella di simulare il tutto con dei tasti che al click di ognuno parte una activity. Ma una Activity aggiuntiva apre un layout a tutto schermo o può essere anche limitato all'interno di una pannello su un layout principale?
 
Last edited:

udg

Expert
Licensed User
Longtime User
E parlando di ActionBar potresti dare un'occhiata anche alla mia lib dgActionBar che in realtà è più un pannello di comando da posizionare liberamente sulla pagina che una vera AB. E' formato da un menu logo, da un numero indefinito di icone di comando e dal classico menu a cascata, tutti opzionali.
Dovrebbe poer funzionare su tutte le versioni di Android.

Umberto
 
Top