Android Question [Resolved] - ScrollView - multiple layout

AymanA

Active Member
Licensed User
Hi All,

Can someone suggest how to have two layouts loaded in the same panel under scrollview?

What I want to achieve is loading 2 layout files (each contains panel --> that contains some buttons and labels) on a panel under each other, sure the command below show them on the same position so they appear over each other.

Thank you for your help!

B4X:
Dim p As Panel
p.Initialize("")
p.SetLayout(0,30dip,100%x,210dip)
ScrollView1.Panel.AddView(p,0,0dip,100%x,210dip)
p.LoadLayout("view1")
p.LoadLayout("view2")
 

LucaMs

Expert
Licensed User
Longtime User
BTW, you have not really explained what you are actually trying to achieve...
1580858517303.png
 
Upvote 0

AymanA

Active Member
Licensed User
@AymanA you should load one layout and use 2 panels to get the results that you are looking for. You can easily switch between the two panels.

But saying that, if you really do need 2 layout files, then you should be using 2 activities, especially as it will make managing your code a lot easier to achieve.

BTW, you have not really explained what you are actually trying to achieve...

Apologies, I have the question in my mind crystal clear, but definitely it is not clear for others! let me provide more details.

so below explain what I am after:

1580864930275.png


but below is what I currently have with the code mentioned, so I am not sure how to achieve one panel or view to appear under the other:

1580865115931.png


I have attached an example that shows my current files and code.

Note: in the file attached:
view1 = floor_view
view2 = wall_view

I am happy to change my logic if this is not doable.
 

Attachments

  • EXAMPLE1.zip
    15.7 KB · Views: 180
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Just a (quick) test.

[Take a look also to CLVExpandable, maybe it's for you]


[EDIT] I hope it's because of this night time... you want to use a ScrollView and I used a xCustomListView! :(
Well, if needed, you can change it easily.
[P.S. Attached also a bad ScrollView version]
 

Attachments

  • xCLV.zip
    12.4 KB · Views: 165
  • ScrollViewExample.zip
    12.3 KB · Views: 170
Last edited:
Upvote 0

AymanA

Active Member
Licensed User
Just a (quick) test.

[Take a look also to CLVExpandable, maybe it's for you]


[EDIT] I hope it's because of this night time... you want to use a ScrollView and I used a xCustomListView! :(
Well, if needed, you can change it easily.
[P.S. Attached also a bad ScrollView version]

Thank you so much LucaMs for your help, I think I will go with the CLVExpandable, as it looks better.

Just out of curiosity why do you refer to the ScrollViewExample as bad scrollview? this is not a recommended method?
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Thank you so much LucaMs for your help, I think I will go with the CLVExpandable, as it looks better.

Just out of curiosity why do you refer to the ScrollViewExample as bad scrollview?
Because I have not taken good care of the size of the views.

this is not a recommended method?

1580959100125.png


I don't know what your activity should be and why you want or need to use a ScrollView (or a CustomListView).

1 - two panels, added directly to the Activity, may be sufficient;

2 - you may need only two panels but very high, whose sum of heights is greater than that of the screen. In this case a ScrollView is the ideal choice;

3- if you need N pairs of panels, CustomListView is the view to use.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Attached you find a very simple ScrollView example with two Panels.
For simple layouts or lists I prefer ScrollViews.
It has three layout files, the main layout with the ScrollView and one layout for each Panel.
The code is very simple:
B4X:
Sub Globals
    Private scvTest As ScrollView
    Private pnlTest1, pnlTest2 As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Main")

    scvTest.Panel.LoadLayout("Panel1")
    scvTest.Panel.LoadLayout("Panel2")
    pnlTest2.Top = pnlTest1.Height
    scvTest.Panel.Height = pnlTest1.Height + pnlTest2.Height
End Sub
 

Attachments

  • SrcollViewTwoPanels.zip
    11.1 KB · Views: 192
Upvote 0
Top