Reputation: 51421
Is it somehow possible to listen to touch gestures on an ActionbarSherlock? I would like to recognize swipe gestures on the Actionbar in order to "pull down" a pulldown menu from the top of the display.
Upvotes: 0
Views: 420
Reputation: 23977
You can detect gestures for a whole Activity
, where you can implement onTouchEvent()
callback and use GestureDetector
.
Detecting touches and gestures only for the action bar is problematic.
AFAIK, the action bar does not expose its views. So there's no api for attaching OnTouchListener
to native action bar. It won't work there unless you do some hacking into the private parts of the ActionBar. Or you could create a custom view with the OnTouchListener
in the action bar, then you could detect touches in the area of the custom view. You can set the custom view to take the whole area of the action bar.
Similar situation holds for ActionBarSherlock
(it is used for all version up to Android 3.2). But the situation here is more favorable, since it is a library you add to your project, you can freely manipulate it any way you want and you can easily access its private parts. ActionBarSherlock
mimics the native action bar by adding some extra views to the window content. You can access these views and attach OnTouchListener
to them (you would probably use R.id.abs__action_bar
or R.id.abs__action_bar_container
).
Upvotes: 1