• Stars
    star
    343
  • Rank 123,371 (Top 3 %)
  • Language
    Java
  • License
    BSD 2-Clause "Sim...
  • Created over 12 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A slide-out navigation (a.k.a. "Drawer") implementation for Android applications

Undergarment

NOTE: Undergarment is deprecated. Please use the official DrawerLayout implementation located in the v4 Support Library.


A slide-out navigation (a.k.a. "Drawer") implementation for Android applications.

The slide-out navigation pattern has been popping up in all sorts of places in the Android ecosystem lately in all sorts of shapes and sizes. Undergarment initially started with me mimicking the experience found in the Prixing application, as documented by Cyril Mottier in his series of three blog posts on the subject.

Just recently (August 2012), the Android team updated their Design site specifically with a new pattern documenting the slide-out navigation every developer and their dog had been playing around with to that date. Thusly, the "Drawer" pattern was born. You can find the Android team's documentation regarding the Drawer pattern under the "View Controls" section of the Action Bar patterns page.

Now, as the Prixing implementation dealt with sliding the entire window (Action Bar and all) over to the side in order to reveal the "drawer" while the pattern on the Android Design site used the YouTube app as a reference, which slides only the content portion over and keeps the Action Bar stationary, my implementation was a bit lacking. So, I added support for sliding just the content portion over, moved the implementation into a standalone Android Library project, and put it on GitHub. That's the story of how Undergarment was born.

Using & Such

I'm a fan of git submodules (and IntelliJ), so in order to use this library I recommend adding this repository as a submodule of your encompassing project's repository:

git submodule add git://github.com/eddieringle/android-undergarment contrib/android-undergarment

Now add the Undergarment library as a module in IntelliJ and add that module as a dependency of your project. You're then ready to start using Undergarment!

Integrating Undergarment is fairly straightforward. In the onCreate of the Activity hosting the Undergarment (a.k.a. "Drawer") do a little something like this:

mDrawerGarment = new DrawerGarment(this, R.layout.dashboard);

The constructor takes two arguments, the first being the Activity that hosts the Undergarment and the second being a resource identifier to the layout that will define the drawer contents.

By default, Undergarment is set to slide the entire window over, Action Bar and all. If you wish to switch to the YouTube-style of only sliding over the content then you can set it like so:

mDrawerGarment.setSlideTarget(DrawerGarment.SLIDE_TARGET_CONTENT);

When the drawer is first attached to the view hierarchy, Undergarment sets the background color of the content view to Color.WHITE. The reason it is not transparent (or left alone) is because the drawer would otherwise show through to the content view, making things look messy and such. If a white background won't work and, for instance, red is more your style, you can change it like so:

mDrawerGarment.setDecorContentBackgroundColor(Color.RED);
mDrawerGarment.reconfigureViewHierarchy();

To open and close the drawer, call the openDrawer() and closeDrawer() methods, respectively. You can also toggle the drawer state with the toggleDrawer() method. The user will also be able to control the drawer by bezel swiping from the left side of the screen to open the drawer and doing the same from the right to close it. If you want to prevent this touch functionality, you can call setDrawerEnabled(false).

Finally, you can provide callbacks to the drawer that will fire when the drawer is opened or closed, which allows you to do useful things such as modifying the state of the Action Bar. To set the callbacks, implement the DrawerGarment.IDrawerCallbacks interface and add them to the drawer with setDrawerCallbacks(callbacks).

More Repositories

1

hubroid

The Original & Awesome GitHub App for Android
Java
304
star
2

portaudio

Unofficial Git mirror of PortAudio
C
68
star
3

ghapi

A Java wrapper for the GitHub API
Java
28
star
4

andicons

Android library for using font-based glyphs as Drawables and Bitmaps in Android applications
Java
20
star
5

PasswordMaker_X

A PasswordMaker app for Android that's easy on the eyes
HTML
15
star
6

clion-cmakedocs

CLion plugin to enable Quick Documentation for CMake commands, modules, properties, and variables.
Kotlin
13
star
7

wicketpixie

A free social media WordPress theme
JavaScript
12
star
8

SDL

Unofficial Git mirror
C
11
star
9

p3_eav

The Pirillo Power Pack for Empire Avenue
JavaScript
8
star
10

HoloGraphLibrary

Gradle-fied HoloGraphLibrary
Java
4
star
11

andy_platformer

An unnamed platformer
Java
3
star
12

DesireLED

LED application and library for the HTC Desire
Java
2
star
13

barr

A dynamic bit array, I guess.
C
2
star
14

statesman

Kotlin
2
star
15

toluapp

Git mirror of tolua++ SVN
C
2
star
16

erbium

C
2
star
17

mapp-wordpress

Multi-Author Payment Plugin for WordPress
PHP
2
star
18

inceku

A Portable HTTP Server built on the CrissCross Library
C++
2
star
19

wordpress-author-minus-publish

Removes Publish capability from WordPress' Author role
PHP
1
star
20

wicketpixie-old

A free social media WordPress theme from Chris Pirillo
PHP
1
star
21

NutsNBolts

Common boilerplate code for Android development
Java
1
star
22

crea

C's soulmate
C
1
star
23

mo

Some sort of Android View presentation framework
Kotlin
1
star
24

openal-soft

C
1
star
25

turfs

"Get off mah lawn, platform gnostics."
C
1
star
26

glew

Unofficial mirror of GLEW + pre-generated source files (i.e., glew.c)
C
1
star
27

lua-es

Lua + turfs + other cool stuff
C
1
star
28

idlecrawler-ruby

A web page crawler written in Ruby
Ruby
1
star
29

rudy

Kotlin
1
star
30

kotlin-android-demo

Kotlin
1
star
31

SDL_image

Mirror of Mercurial repository
C
1
star
32

funicode_crx

Funicode.com in the form of a Chrome Extension
JavaScript
1
star
33

EAvROI

A tiny Chrome extension that injects an investment's daily ROI into an EAv page.
JavaScript
1
star