Adding Layouts to Sliding Panels

JonPM

Well-Known Member
Licensed User
Longtime User
B4X:
Dim pan(2) As Panel
pan(0).LoadLayout("mylayout1")
pan(1).LoadLayout("mylayout2")
sd.Initialize
SlidingPanels.Initialize(sd, panels, True, 150)
 
Upvote 0

iTzCorky

Member
Licensed User
Longtime User
B4X:
Dim pan(2) As Panel
pan(0).LoadLayout("mylayout1")
pan(1).LoadLayout("mylayout2")
sd.Initialize
SlidingPanels.Initialize(sd, panels, True, 150)

Hey thanks Jon I actually figured it out before this was answered lol. But now im having an issue with my layout that I load. My layout has a listiview on it and the code just adds two lines and a bitmap when I go and test it, it cuts off the bottom of the listview. Any ideas?
 
Upvote 0

iTzCorky

Member
Licensed User
Longtime User
Here is the activity create code if it helps oh and also I have tried the 100%x and y and that did not work either. Where the loadlayout "test" is, is the listview layout.

B4X:
Sub Activity_Create(FirstTime As Boolean)
   
   Dim Pan(2) As Panel
            
            Pan(0).Initialize("")
            Pan(1).Initialize("")
            
            'Initialize the panels we use for the pages and put them in the container
      Container.Initialize
            
            Pan(0).LoadLayout("test")
            Container.AddPageAt(Pan(0), "test", 0)
            
            Pan(1).LoadLayout("generationlayout")
            Container.AddPageAt(Pan(1), "Generation Info", 1)
            
      'Now we have a container with our panels just add it to the pager object
      Pager.Initialize(Container, "Pager")
   
      'As we want to show the tabs page indicator, we initialize it
      Tabs.Initialize(Pager)
      Tabs.LineHeight = 5dip
            Tabs.LineColorCenter = Colors.Green   
            Tabs.TextColor = Colors.Gray
            Tabs.TextColorCenter = Colors.Green

            Activity.AddView(Tabs, 0dip, 0dip, 100%x, 100%y)
            
      'We add a line below the tab page indicator because it looks good
      Dim Col As ColorDrawable
   
      Col.Initialize(Colors.Green, 0)
   
      Line.Initialize("")
      Line.Background = Col
   
      Activity.AddView(Line, 0dip, 35dip, Activity.Width, 2dip)            
   
      'Now we can add the pager to the activity
      Activity.AddView(Pager, 0dip, 35dip + 2dip, Activity.Width, Activity.Height - 35dip - 2dip)
 
Upvote 0

JonPM

Well-Known Member
Licensed User
Longtime User
Can you upload your project, or a sample project? What exactly did you set to 100%y? Did you change the layout of the panel/listview?
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User
I am having the same problem, and i am using the same code you got as a start code for sliding panels.

It seems that the LoadLayout loads ok but calculate everything based on screen size without considering the top tabs.

My problem is that i have defined one panel that holds buttons on the bottom of the screen in the bal file:

FooterPanel.botton = 100%y

And it get cut for around 30dip, around the same size of the top tab. This is my guess. I am not sure about that yet.

Did you find a solution?

I was looking for recalculate the bal scripting, but I am not finding where I read about that, calling from the code.


EDIT:
I made more testing and what is hapening is that there is 37dip space used on the top by the tab. The layout file is seems to be considering the screen size instead of the panel it is getting loaded. So 100%x and 100%y is based on the screen.

My quick workaround was creating a value in the script layout "bottom" that i am assigning 37dip and adding it to the calculations where it is needed.

But I wanted to get something automatic, even it is needed to call a function that recalculate after the layout is inserted.

Thanks to any help
 
Last edited:
Upvote 0
Top