Carbodrache
Carbodrache

Reputation: 81

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

Upvotes: 8

Views: 1426

Answers (3)

Kowlown
Kowlown

Reputation: 1166

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.

Upvotes: 1

marmor
marmor

Reputation: 28229

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.

Upvotes: 2

adamp
adamp

Reputation: 28932

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.

Upvotes: 3

Related Questions