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: 9,833
Last edited:

anglia

Member
Licensed User
Longtime User
Thanks Erel,
I've looked at ScrollView2D and can't see how it helps me. It looks as if ScrollView2D is used to move horizontally and vertically on a single image.
What I want to do is have 2 panels, each having an Imageview. I want to be able to slide the panels horizontally and vertically after loading a new image in the Imageview that is about to be moved. I have a large chart diagram which I've chopped into 800 png files ( 40 across x 20 down) -each 256x256 pixels, each approx 30kB in size.
When I click the 'up' button I want to see the image in the row above and when I click the 'right' button I want to see the image in the column to the right etc.
I've tried all sorts of combinations with your SlidingPanels but I just can't get it to work.
I'd be very grateful if you could advise.
 
Top