Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make a side bar like Dolphin browser or Firefox in android

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 :-)

like image 508
Carbodrache Avatar asked Jan 08 '11 20:01

Carbodrache


3 Answers

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.

like image 85
adamp Avatar answered Nov 10 '22 07:11

adamp


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.

like image 2
marmor Avatar answered Nov 10 '22 05:11

marmor


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.

like image 1
Kowlown Avatar answered Nov 10 '22 07:11

Kowlown