Android Question [SOLVED] Scroll panel to show all views

jroriz

Active Member
Licensed User
Longtime User
I need to create several views dynamically.
As there will be several views, I used a scrollview.
However, after creating the views, I don't know how to resize the panel so that the user can scroll it to the end, so that he can see any view he wants.

Below is my code and the sample project is attached.

svcInspecao is in "inspecao" layout.
pnlFormulario is in "meapague" layout.
lblPergunta is in "campotexto" layout.

My code::
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private svcInspecao As ScrollView
    Private pnlFormulario As Panel
    Private lblPergunta As Label
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    
    Root.LoadLayout("inspecao")
    svcInspecao.Panel.LoadLayout("meapague")
    
    Dim ultimo As Int = 100dip
    
    For x = 1 To 10


        Dim p As Panel
        p.Initialize("")
        p.Width = pnlFormulario.Width
        p.Height = 90dip
        p.LoadLayout("campoTexto")

        lblPergunta.Text = "controle " & x
        
        pnlFormulario.Height = pnlFormulario.Height + 90dip

        pnlFormulario.AddView(p, 0, ultimo, pnlFormulario.Width - 11dip, 90dip)
        
        ultimo = ultimo + 100dip


    Next
    
    
End Sub
 

Mahares

Expert
Licensed User
Longtime User
I don't know how to resize the panel so that the user can scroll it to the end, so that he can see any view he wants.
Your project appears to be calling for xCustomListView (xCLv) all over the place. Your project is a very good candidate for xClv if you want to take that approach which is much simpler instead of scrollview and need code or sample project, come back. However, if scrollview is what you want to pursue because you are more familiar with it, then follow Lucas's advice and it can be done.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Your project appears to be calling for xCustomListView (xCLv) all over the place. Your project is a very good candidate for xClv if you want to take that approach which is much simpler instead of scrollview and need code or sample project, come back. However, if scrollview is what you want to pursue because you are more familiar with it, then follow Lucas's advice and it can be done.
Very right. When you have items all of the same type, same layout (or very few different types) it is much better to use CustomListView.
 
Upvote 0
Top