Create a sidebar such as Dolphin or Firefox on Android

I would like to create a sidebar similar to the one found in the dolphin browser or Firefox for Android.

I have a list, which is my main screen, when I swype to the right, I want to move the list to the right and make a new left view.

Like this

thanks

PS: I am a French guy, I regret English :-)

+8
android android widget
source share
3 answers

Take a look at the Workspace widget in the Android Open Source Project Launcher2 code . This is a widget that implements side-to-side paging behavior on the Android Android home screen.

The main idea is to create a custom widget that can pan its contents with rules to snap to the end position if the user drops or releases. Use onInterceptTouchEvent to determine when the user crossed the 'slop' threshold in horizontal movement (you can get system values ​​for this from the ViewConfiguration ) and remove input focus from any child views in the hierarchy. From there, control the panning in onTouchEvent . You can use VelocityTracker to determine how the content should leave when the user releases, and Scroller to help you animate the end position.

+3
source share

Use the 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 scroll to see the hidden sidebar.

+2
source share

You can make a panel with LinearLayout with a width of 0, then you can also use GestureBuilder to define horizontal scrolling and animation to gradually change the LinearLayout width to the desired width.

+1
source share

Source: https://habr.com/ru/post/650842/


All Articles