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

  • SlidingSidebar v1.1 Dw.zip
    38.1 KB · Views: 1,862
Last edited:

Informatix

Expert
Licensed User
Longtime User
When you get time, please go through Google's new guidelines for sliding sidebars and kindly update it based on their recommendations (like dimming the main content panel when the sidebar is open, etc..).

Navigation Drawer | Android Developers

For now, I have no real intent to do so because:
1) I never created this class to be a replacement for a navigation drawer (this class doesn't even exist when I created mine);
2) I currently have no time for this;
3) If you need to dim the sidebar while opening/closing, it's so easy to do (and one of my examples does it) that you don't really need me to add this.

BUT I have nothing against the idea. Just tell me precisely what features are missing and highly expected.
 

CidTek

Active Member
Licensed User
Longtime User
For now, I have no real intent to do so because:
3) If you need to dim the sidebar while opening/closing, it's so easy to do (and one of my examples does it) that you don't really need me to add this.

I tried to find some info on how to dim a panel but searching the forums returns every article that contains a "dim" source code statement.

BTW, its not the sidebar that needs to be in a dim state but rather the panel it is partially covering.

Do you know of any posts that address this?
 

RiverRaid

Active Member
Licensed User
Longtime User
Hi..

I tried to increase the size of the GesturePanel to 100%x, to catch the gesture on the whole screen...

But now, of course, the Buttons on the Activity can not be clicked any more. Is there a way to cast the clicks to the buttons?

Thanks!
 

Informatix

Expert
Licensed User
Longtime User
I tried to increase the size of the GesturePanel to 100%x, to catch the gesture on the whole screen...

But now, of course, the Buttons on the Activity can not be clicked any more. Is there a way to cast the clicks to the buttons?

Thanks!

Yes, you can. In the Gesture_onTouch handler, check if the buttons are concerned by the click, then return False to delegate the event to the underlying button.
 

mcmanu

Active Member
Licensed User
Longtime User
Very nice but is it possible to make the panel hight not so high than the activity?
Because i can not click any button on my Activity when i use this sliding sidebar :(
Because the hole panel is over the activity and my views
 

mcmanu

Active Member
Licensed User
Longtime User
I have an Application with about 100 views on it. When i use the sidebar i can not click any button. When the sidebar is closed i can not click any button on my activity as well. Hope you know what i mean :)

What can i do to use my views, when the sidebar is closed? (sample with the handle)
 
Last edited:

Informatix

Expert
Licensed User
Longtime User
Oh I see your mistake now! SlidingSidebar is not just a sliding menu on a side, it replaces the whole screen. It is made of two panels: the slidebar panel and the content panel. The content panel is meant to hold all the views displayed when the sidebar is closed. Thus, to adapt your application, you have to replace all Activity.AddView by MySlidingSidebar.ContentPanel.AddView.
If you want to limit the SlidingSidebar to a region of your activity, create a panel bounding this region and pass the panel as the first parameter of the Initialize function of the class.
 

mcmanu

Active Member
Licensed User
Longtime User
Oh right, i missunderstood the behavior, thank you very much :)
Okay, then i will give it a try :)
 

IDDGroup

Member
Licensed User
Longtime User
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?
 
Top