Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i create a sliding drawer with menu items?

Tags:

android

How can I create a horizontal sliding drawer like the YouTube and Facebook app has.

enter image description here

Many other apps seem to use use the same style, so I'm guessing that this is a part of the default Androind UI framework but I can't seem to piece it together.

You can see some more samples here.

Thanks.

like image 466
Mridang Agarwalla Avatar asked Aug 19 '12 16:08

Mridang Agarwalla


2 Answers

This is a sliding menu, you can implement this by writing a custom view. There are a lot of good open source examples. I would recommend you to use this one.

You can use it by defining this in your Layout:

<com.slidingmenu.lib.SlidingMenu
    xmlns:sliding="http://schemas.android.com/apk/res-auto"
    android:id="@+id/slidingmenulayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    sliding:viewAbove="@layout/YOUR_ABOVE_VIEW"
    sliding:viewBehind="@layout/YOUR_BEHIND_BEHIND"
    sliding:touchModeAbove="margin|fullscreen"
    sliding:touchModeBehind="margin|fullscreen"
    sliding:behindOffset="@dimen/YOUR_OFFSET"
    sliding:behindWidth="@dimen/YOUR_WIDTH"
    sliding:behindScrollScale="@dimen/YOUR_SCALE"
    sliding:shadowDrawable="@drawable/YOUR_SHADOW"
    sliding:shadowWidth="@dimen/YOUR_SHADOW_WIDTH" />

Edit:

The Android team introduced an official sliding pattern on Google IO 2013. Read everything about it here.

like image 198
Ahmad Avatar answered Oct 12 '22 13:10

Ahmad


As far as I know it is not part of the default framework. This is the only place I can find it mention in the Android docs http://developer.android.com/design/patterns/actionbar.html and I have search quite a bit.

This so far has been my favorite library https://bitbucket.org/verdigo/drawer/ straight forward and easy to use.

Also pretty recently HoloEverywhere library added a drawer you can use. This one interests me since I use HoloEverywhere in most of my apps and it looks very similar to Foursquares. https://github.com/Prototik/HoloEverywhere

like image 40
Pieces Avatar answered Oct 12 '22 12:10

Pieces