Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swipe to switch tab selection

I have an application that is a Tab activity with various tabs that load an Activity. I would like to add swipe gesturing to switch between tabs, on both the tab control itself and each activity loaded in a tab. Is something like this possible? I'm not sure at what "depth" the gesture is listened to when you're making gestures on an Activity hosted in the tab control, or if the inner activities would have to pass data to the Tab Host.

like image 440
Stealth Rabbi Avatar asked Apr 12 '11 13:04

Stealth Rabbi


1 Answers

It's certainly possible; you'll need to write a custom layout and override onTouchEvent and onInterceptTouchEvent to decide whether to dispatch gestures through to the children . See HorizontalPager's source for details on how you could go about doing that. You actually may just want to use HorizontalPager straight up (there's a demo on simulating tabs with it), as I think the scrolling content makes it much clearer that you can swipe between tabs.

like image 142
Yoni Samlan Avatar answered Oct 08 '22 16:10

Yoni Samlan