B4A Library [Class] SlidingSidebar

Hello,

With this class, you can put an hidden sidebar on one of the four sides of the screen and reveal it when needed. It can open with a button, like in the Facebook app, with a handle, as the standard Android slidingdrawer, or with a swipe gesture, like in Prixing. Many options are available to suit all needs.

List of functions:
Initialize(Parent As Panel, SidebarSize As Int, SidebarPosition As Byte, AnimType As Byte, OpenDuration As Int, CloseDuration As Int)
SetOnChangeListeners(Module As Object, SubOnFullyOpen As String, SubOnFullyClosed As String, SubOnMove As String)
Sidebar() As Panel
ContentPanel() As Panel
SetInterpolator(Value As Float)
OpenSidebar()
CloseSidebar()
IsSidebarVisible()
As Boolean
SetOpenCloseButton(Btn As View)
AddOpenCloseHandle(Hdl As View, Position As Int, Width As Int, Height As Int, FinalMovement As Byte)
EnableSwipeGesture(Enabled As Boolean, GestureAreaSize As Int, FinalMovement As Byte)
LoadDrawable(Name As String) As Object

Since September 3rd 2014, the SlidingSidebar class is completely free.

img1.png img2.png img3.png

v1.1: Fixed three bugs and optimized the animation function
 

Attachments

Last edited:
Trying to just run the sample programs. using a nexus 5 (kitkat) and B4a 3.

on the SlidingDrawer, and SlidingSidebar examples, i am getting:

java.lang NoSuchFieldException: left_Shadow

on line 82

ID_Drawable = r.GetStaticField(package & ".R$drawable", ImageName)

is there some change that is causing it not to work?
You probably forgot to copy the files in the res folder or you changed their attributes (they have to be read-only).
 
you are right. actually i use a Mac (running b4a under parallels), apparently when you unzip on a mac, it doesnt save the attributes on the files, makes them all R/W.

I am playing with the slidingsidebar demo. seems the slide is very jerky (using a Nexus 5), is there a way to change the timing of the slide?

also, is there a way to force the menu to display/hide?
 
I am playing with the slidingsidebar demo. seems the slide is very jerky (using a Nexus 5), is there a way to change the timing of the slide?
To smooth all this, add the following to your manifest:
SetApplicationAttribute(android:hardwareAccelerated, "true")

also, is there a way to force the menu to display/hide?
I'm not sure to understand your question because it's what the ListView does in the demo when you click on an item.
 
Excellent work, I love it!
Anyway, can I use this class commercially? I will donate if it is required.
Thanks
 
Hi, Is there a way to make it so the side menu like in the SlidingSidebar demo so when you side the menu out from the side of the screen move the menu over the top of the main page.

In the SlidingSidebar demo it moves the main screen to the right as the page opens. I want the blue background part of to stay there while the menu moves over the top.

Is this possible ?
 
Hi, Is there a way to make it so the side menu like in the SlidingSidebar demo so when you side the menu out from the side of the screen move the menu over the top of the main page.

In the SlidingSidebar demo it moves the main screen to the right as the page opens. I want the blue background part of to stay there while the menu moves over the top.

Is this possible ?
Did you try to change the SidebarPosition and AnimType parameters ?
 
That did it. I didn't have it set in the Initialize parameter.

Thanks for your help.
 
Your class is really useful and it helped me to give my app a better look. Thank your job and for share it.

I send you a little donation (a beer, more or less) ;-)

Cheers!
 
Possibly a naive/newb question, but I don't get it. In the SlidingSideBar sample, how is it that the colour and form of the sidebar is different in landscape and portrait modes? There seems to be nothing in code that changes it.

SSBPortrait.png SSBLandscape.png
 
Possibly a naive/newb question, but I don't get it. In the SlidingSideBar sample, how is it that the colour and form of the sidebar is different in landscape and portrait modes? There seems to be nothing in code that changes it.

View attachment 36804 View attachment 36805
This demo uses a drawable provided with the Android system: jog_tab_bar_right_end_normal. It is paint in the background. Nothing else.
 
Is it possible to make the background of the SlidingSideBar less transparent?
(I suppose it is the jog_tab_bar_right_end_normal)
 
I "solved" it by putting a semi-transparent panel over the contentpanel on fully-open and remove it on fully-closed. This is a nice effect as well ;)
 
Hi to all,

I have a problem with this cose

Code:
    MenuBar.Initialize("")
    MenuBar.Color = Colors.Gray
    Activity.AddView(MenuBar,0%x,0%y,100%y,45dip)
   
    MenuButton.Initialize("MenuButton")
    MenuButton.BackgroundColor = Colors.Transparent
    Dim bm As BitmapDrawable
    bm.Initialize(LoadBitmap(File.DirAssets,"ic_menu_white_24dp.png"))   
    MenuButton.setIcon(False,bm)
    Activity.AddView(MenuButton,0%x,0%y,50dip,45dip)

    TopBar.Initialize("TopBar")
    TopBar.Color = Colors.Gray
    PanelWithSidebar.ContentPanel.AddView(TopBar,0%x,0%y,100%y,45dip)
   
    Lbl_TopBar.Initialize("Lbl_TopBar")
    Lbl_TopBar.Gravity = Gravity.CENTER_VERTICAL
    Lbl_TopBar.Typeface = Typeface.DEFAULT
    Lbl_TopBar.TextSize = 14
    Lbl_TopBar.Color = Colors.Red
    Lbl_TopBar.Text = "Prova Label Tracker"
    TopBar.AddView(Lbl_TopBar, 20%x, 2%y, 45dip, 40dip)

the Label Lbl_TopBar does not show on the Panel TopBar

how can I fix this?

Thanks
 
solved with this

Code:
MenuBar.AddView(Lbl_TopBar, 50%x, 2%y, 80%x, 40dip)

Thanks
 
I'm using your class and some people report an error connected to it (see below). On the majority of phones this error doesn't happen. I have a S4 (5.0.1), a S4 mini (4.4) and a S3 mini (4.1) to test and on none of these phones the error shows up.

Can you please tell me how to solve this?
Can you please tell me how to reproduce it (so i can work on it on my testing phones)?

Thanks for helping :)

Code:
An error has occurred in sub.clsslidingbar_vv7 (java line: 926)
android.content.res.Resources
$NotFoundException:Resource ID #0x0

or:

Code:
An error has occured in
sub:clsslidingsidebar_loaddrawable(java line: 925)
android.content.res.Resources$NotFoundExeption:
Resource ID #0x0
 
Back
Top