I would like to create a sidebar like the one in dolphin browser or firefox for android.
I have a listview that is my main screen, when I swype to right I wish to move the listview to right and make appear a new view on the left.
Like this
Thanks
PS : I'm a french guy sorry for the english :-)
Take a look at the Workspace
widget in the Android Open Source Project Launcher2 code. This is the widget that implements the side to side paging behavior on the stock Android home screen.
The basic idea is to create a custom widget that can pan its contents with rules for snapping to a final position if the user flings or lets go. Use onInterceptTouchEvent
to determine when the user has crossed a 'slop' threshold in horizontal motion (you can get the system values for this from ViewConfiguration
) and steal away input focus from any child views in the hierarchy. From there, control the panning in onTouchEvent
. You can use a VelocityTracker
to determine how the content should fling when the user lets go and a Scroller
to help you animate to the final position.
Use ViewPager supported by the Support-V4 package, you can put Fragments
in it, one for your main screen, and another for your sidebar, and then the user can swipe to see the hidden sidebar.
You can make the pane with LinearLayout with a width at 0, then you can use also GestureBuilder to detect horizontal swipe and Animation to change progressively the widthof your LinearLayout to the desired width.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With