TextInputLayout – Material Design Support library Tutorial

This time in Google I/O 2015, it come up with Android M developers preview announcement and lots of other stubs which increase developers to be Materialized.

Recently Google has released Android Support Library 22.2.0. In that we are going to explore “Design Support Library”.  It has lots of new widgets which will definitely helpful to the developers.

Each widget has its own characteristic. So we will learn all of them but step wise. Today’s our topic to learn is “TextInputLayout“.


Layout which wraps an EditText (or descendant) to show a floating label when the hint is hidden due to the user inputting text.

This layout helps user to show first “hint” and when user taps on , hint will come up with text over it as floating label and user is allowed to enter text.

What is problem with Traditional EditText?

When we are using EditText, we need to take care for adding hint to it. But with traditional EditText, when user starts typing, hint will be gone and no more visible until EditText is empty. To overcome, we can also use TextView as a label over it. But we need to take care of by aligning them with proper spaces, font sizes, font types and colors.

How to use?

First you need to add support library to your project. To do that follow the steps.

Step – I

Open your SDK manager  and check whether Android Support Library is updated with 22.2 version or not.

1. Android Support Library
1. Android Support Library

You need to install 2 packages

Android Support Repository - Rev 16
Android Support Library - Rev 22.2

Step – II

After that you need to add dependency to your gradle file. If you have already created android project then open your application gradle file (app/build.gradle) and paste following source of code in it. Else first learn How to create a project in Android Studio?

After adding dependencies, gradle file will look like below.

2. Android Support Library
2. Android Support Library

Thats it. You are done with adding support library to your project. Now move to the part of using TextInputLayout.

Step – III

To use TextInputLayout, it requires EditText as its child. It will take up its child property and will display layout accordingly.

You can see here that to use TextInputLayout, we need to use full class path of design support library and inside it we need to pass EditText as child. We have to pass hint in EditText to show floating label to your view.

Now open your layout file and paste following code in it.

In this layout, we took 3 TextInputLayout. First Name, Last Name and Email fields. Each has its own hint attribute.

Step – IV

Final step. Run your application.


Full source code at Github.


In this article, we have learn about what is TextInputLayout. How it is different then EditText and what are the benefits of using it.

Share on Facebook18Share on Google+0Tweet about this on TwitterShare on LinkedIn0Share on Reddit0Pin on Pinterest0Share on Tumblr0Email this to someone