Android Design Support Library

Google introduced the Android Design Support Library which brings a number of important material design components to developers. The components are backwards compatible, with support back to Android 2.1 and implementing them is easier than previously. The library includes a navigation drawer view, floating labels for editing text, a floating action button (FAB), snack bar, Tabs view.

The Design Support Library can be included in your Android projects by importing the Gradle dependency.

          compile ''

Navigation View:

The NavigationView makes it easy to create Material Design-style side drawer layouts. It consists of the header and the menu.


              android:layout_height="match_parent" />

                   app:menu="@menu/drawer" />


This view supports two key attributes:

Header Layout:

The optional headerLayout attribute is used to declare a layout to be used for the header section of the Drawer. This is the space shown above our navigational items, a common use is a profile section header.


The menu attribute is used to declare the menu resource to be used for the navigation items in the drawer. It is also possible to call inflateMenu() to inflate a menu programmatically.

<menu xmlns:android=""

       <group android:checkableBehavior="single">
                            android:title="@string/home" />
                            android:title="@string/messages" />

                            android:title="@string/friends" />

                            android:title="@string/discussion" />

Floating Action Button:

A floating action button is a round button denoting a primary action on your interface. The Design library’s FloatingActionButton gives you a single consistent implementation, by default colored using the colorAccent from your theme.

With the Design Support Library, floating action buttons can be included in a layout with a few simple lines of XML. Each button is easily customizable with icons and colors. Two sizes are available, standard(56dp) and mini (40dp).

         android:src="@drawable/ic_fab" /

Snack Bar:

Snackbars are like Toasts, but a bit more flexible. A snackbar contains an action and can be dismissed.

Snackbars are shown on the bottom of the screen and contain text with an optional single action. They automatically time out after the given time length by animating off the screen. In addition, users can swipe them away before the timeout.

            .make(view, R.string.snackbar_text, Snackbar.LENGTH_LONG)                         .setAction(R.string.bar_action, mOnClickListener) 

Floating Labels for EditText:

The new TextInputLayout allows us to wrap EditText views in order to display floating labels above the EditText field. When an EditText has focus, the assigned hint will ‘float’ above the view to the top-left hand side. This is useful as it still provides context to the user whilst data is being input.

To implement this we just wrap our EditText in the TextInput Layout:

              android:layout_height="wrap_content" >

                android:hint="@string/hint_email" />


No comments:

Post a Comment