Android Tutorial Android SlidingPanels - Simple way to create sliding layouts

This is an old tutorial. There are now simpler and better ways to achieve this effect.

For example: https://www.b4x.com/android/forum/threads/tabstripviewpager-better-viewpager.63975/

Sliding layouts are cool.

Using the Animation library it is not difficult to animate single views and panels that hold other views.
The following code module and example project makes it even simpler to create a layout that is made of a number of panels. Whenever the current visible panel is changed, the current panel slides out and the new panel slides in.
As Panels can load layout files, you can create complex layouts by loading a layout file to each panel.

slidingpanels_1.png


The project is made of two components. The Main activity and the SlidingPanels code module.
You should add the SlidingPanels code module to your project and add a reference to the Animation library.

The main activity code is commented and explains the several integration points required.

Animations look much better on real devices than on the slow emulator.
Even if you are not interested in sliding layouts it is recommended to go over the code. It demonstrates the power of custom types which enable you to easily group many objects.
As code modules cannot hold references to Activity objects (like views), the calling activity passes the type with all the required data each time it calls a method (passing the data is done by passing a single pointer, there is no overhead here).

Questions and comments are always welcomed.
 

Attachments

  • SlidingPanels.zip
    6.9 KB · Views: 10,010
Last edited:

gelay

Member
Licensed User
Longtime User
Hi Guys

I've loaded a layout with a few buttons on one of the scroll panels and unfortunately, if my finger touches the buttons first, the screen will not scroll. Is there any solution to put the main focus on the sliding function? I use this method for vertical scrolling. For the horizontal scrolling I use the Navdrawer and has no issues like this....

Thanks
Krisztian
 

Johan Schoeman

Expert
Licensed User
Longtime User

gelay

Member
Licensed User
Longtime User
Try this...

It's the same...not working.
Maybe I wasn't clear enough, I don't need swipe buttons.. My problem is this... If I try to swipe up or down simply on the empty panel everything worx like a charm, but if I place buttons on the panels like in the sample and try to swipe up or down above them the swipe isn't working. Its something like the buttons have the focus not the swipe gesture or something. The swipe is only recognized on "empty" places.
Try to swipe above the buttons and you will see it.

Thanks
Krisztian
 

RUNO

Active Member
Licensed User
Longtime User
Hi all .
I have an idea to make a book with 500 photos Can I do without effect on memory and be fast application ؟
I want use sliding panel .
Every image = 70 kb a proximity.
 

Mark Thorndyke

Member
Licensed User
Longtime User
Liking this and works well on an android wearable with images & text embedded. But is there a simplistic way to click a image/button/text under the panel and call a subroutine? (The image not full screen and hence able to keep on swiping through) or am I barking up the wrong tree with this and need to look at alternatives?
 

Mark Thorndyke

Member
Licensed User
Longtime User
I appear to be struggling getting touch events through to the internal view for some reason - doesn't want to play with me :-( Will scratch my head for a few days to why , probably overlooked something and missed the obvious.

I had a look at the TabStripViewerPager tutorial (https://www.b4x.com/android/forum/threads/tabstripviewpager-better-viewpager.63975/) which works well but don't require the menus - as it's for a wearable. If available without the tab strip, perfect.
I've since looked at @Dominex [Class] Multi Type SlidingPanels (https://www.b4x.com/android/forum/threads/class-multi-type-slidingpanels.23303/) and the classic full screen in there works with click/long click which helps a cause but code is far longer than the two above.
 
Last edited:

Mark Thorndyke

Member
Licensed User
Longtime User
Back to the TabStripViewerPager - I notice taking the Custom Views for Tab height, indicator height and underline height to 0 removes these and thus is what I am looking for. Will use that as ticks all boxes :)
 

anglia

Member
Licensed User
Longtime User
I've tried Erel's Slidingpanels successfully with horizontal sliding. i also tried another example that allows vertical sliding. I've been trying to combine both horizontal and vertical slidin in the same app. I've spent hours of trying various animation combinations without success. Can anyone suggest a solution or an example please?
 
Top