Android Question How To Load Panel Into ScrollView??

HimeAnator

Member
Licensed User
Longtime User
I'm trying to load a panel with all of its child views into a scroll view but I am failing miserably.
I have an activity that when a button is pressed a panel will pop up asking for information, but a lot of information is asked for so the panel goes outside the viewing area. I've tried setting up a scroll view and then loading the panel into it but nothing shows at all, just blank.

B4X:
Dim ScrollView1 As ScrollView
ScrollView1.Initialize(InfoPanel.Height)
ScrollView1 .Panel.Height = InfoPanel.Height + 50dip
ScrollView1 .RemoveView
ScrollView1 .Panel.AddView(InfoPanel,0,0,100%x,100%y)

Also tried adding
B4X:
For Each v As View In InfoPanel.GetAllViewsRecursive

Next
but no luck.

Ive used the method described in the tutorial here but I don't want to load another layout.
 

LucaMs

Expert
Licensed User
Longtime User
InfoPanel and ScrollView1 are children of same Activity?

If it is so, you should remove InfoPanel from the activity, Activity.RemoveViewAt(x) if x is the InfoPanel "index", then use ScrollView1.Panel.AddView(PanelInfo...
 
Upvote 0

eps

Expert
Licensed User
Longtime User
I haven't seen Klaus' code from that example, but you should be doing something along the lines of :

B4X:
    ScrollView1.Panel.Height = 200dip * Bitmaps.Size 'Set the inner panel height according to the number of images.

    For i = 0 To Bitmaps.Size - 1

        Dim iv AsImageView'create an ImageView for each bitmap

        iv.Initialize("") 'not interested in any events so we pass empty string.

        Dim bd AsBitmapDrawable

        bd.Initialize(Bitmaps.Get(i))

        iv.Background = bd 'set the background of the image view.

        'add the image view to the scroll bar internal panel.

        ScrollView1.Panel.AddView(iv, 5dip, 5dip + i * 200dip, ScrollView1.Width - 10dip, 190dip)

    Next

Which is from another tutorial iirc.

You need to ensure that you add each panel one by one, adding them to the 'end' of where the previous panel finished. which is the last line above, inside the For Loop. You then also need to ensure that the ScrollView itself is given a size, which I'm sure you have.

I'm a little confused by your statement Panel and all it's children I think you need to expand that slightly or give us some more code to go on, as in what the children are, etc.. Otherwise I don't think it's possible to help you as quickly as I'm sure you'd like.

ScrollView is great, once you get it working, but it can be a real pita to get it working and it's fiddly as it's effectively a manual process on all fronts as opposed to ListView which sorts out a lot of the sizing for you.
 
Upvote 0

HimeAnator

Member
Licensed User
Longtime User
Thank you both for the replies. Sorry if I was lacking on the details. InfoPanel is set up in the designer with text boxes, labels and an image view inside of it. The scrollview is set up using only code and then trying to add the InfoPanel with all of its text fields etc into the scrollview.

I actually mistyped one line of code in the first code sample. Should be...
B4X:
InfoPanel.RemoveView
 
Upvote 0
Top