Android Tutorial Better Sliding Panels with Transparent Top

First off, Erel is the man!

Attached is my result from below:

I researched through the forums and found that people were looking for a way to catch swipe events, without passing them down to the Views below. (because I wanted to do that! ;), but I still wanted Views to receive the events that they would normally get (so buttons, labels, etc still work like expected)

I also found Better Sliding Panels by Markus, and really wanted to use that functionality in my program, but I wanted users to have interaction similiar to when they are using the app drawer, or the home screens. Such that, they can push anywhere on the screen, and start a swipe event. Unfortunately, the ACTION_DOWN event to start a swipe event, is captured by buttons and other views, so no way for Better Sliding Panels to catch swipe events, unless the user always starts the swipe on an empty part of the panel.

(when I use I below, I mean the Royal I, as in WE :) )
With Agraham's Gestures I can use the Listener function to have a transparent panel grab all touch events, and thanks to Erel, I now know how to pass Events down to a View. And thanks to Erel, and Markus, I have a beautiful algorithm for sliding panels.

Basically by overlaying a transparent panel over a Sliding Data Current Panel, (and keeping the two joined at the hip), I pass a down event as a "setPressed" TRUE event, so if the user clicks on a view that changes state based on the Down, (e.g. a Button) then the View changes to match. If the user releases before a LONGPRESS event is generated (currently 500 ms) AND before any movement detected then a click event is passed to the view below. However, if the user starts to move, then the toppanel passes a "setPressed" FALSE event, and Sliding Panels takes over to move the panels.

For a LONGPRESS event, if the View Below consumes it, then topPanel will no longer monitor for Move events (my desired functionality), if the user touched somewhere where a LONGPRESS event is not consumed, then the user can still start to move the Panels.

You could do more with a LONGPRESS, like capture the View that it is going to, and move it around underneath the users finger, just like re-arranging a home screen, but for my use, I just wanted to have a longpress event fire off, and no more motion events monitored.

I've looked through the Android documentation, and looked at the GestureOverlayView, and think this method could also be used to grab Gestures (but don't know how to use the inbuilt Gesture comparison functionality to compare user input with database of possible choices) from a panel. (but you couldn't use it to do that AND move panels, at least not the way Better Sliding Panels works)

Anyway, I thought I would share this, as it may come in handy.

If I am a bit to verbose in the code section, sorry, but I can't remember what I ate for dinner last week, much less remember why I wrote an algorithm the way I did if I don't annotate!

My sample code shows that buttons/labels can be anywhere on a panel, and still recieve their click/longpress events, and that panels can be sized to different shapes, and still work.

Also, I added an AddPanel function, so that Panels can be added "on the fly", but did not add a RemovePanel function, but it would be easy enough.

Hope this helps someone (as I sure banged my head enough getting it to work!)

Ross
 

Attachments

  • BetterSlidingPanelsWithTop.zip
    17.4 KB · Views: 1,034

rclatorre

Member
Licensed User
Longtime User
I'm testing the application but when I press one of the buttons does not enter the Click event:

sub Button_Click
Dim btn As Button
btn = Sender
ToastMessageShow ("click button from" & btn.Tag, False)
End Sub

Apparently this detecting motion and fails to pass control to the button. I have tried to reduce the time: ClickEventLength = 490, but still the same.

Roberto
 

NFOBoy

Active Member
Licensed User
Longtime User
Hrmm,

Inside
Sub toppanel_gesture(o As Object, ptrID As Int, action As Int, x As Float, y As Float) As Boolean

Increase movecount to some higher value... perhaps 10 to 15, and see if that helps to have it pass through...


I have actually started using AHViewPager library, as that is much more User Friendly and works very reliably for my needs.

Ross
 
Top