Home / IOS Development / Add floating label Android for editing text using the Design Support Library

Add floating label Android for editing text using the Design Support Library

When the Android platform was introduced by Google, Android edittext was one of the basic UI widgets. It is used by Android developers to take input from the user. And as you type the text, it usually hides the hint that can create a problem to identify Edittext without label. Google then launched an Android design library consisting of a snack bar, floating action button, floating label in Android for edit text, and floating edittext android.

This floating Android label for edittext is the concept of displaying a label as a hint when the user enters information into edittext. When the user taps on the edit text, the hint moves to the top like a floating hint edittext Android. In this Android app tutorial we will learn how to add this floating label Android for edittext.

Steps to add floating label Android for Edittext

Open Android Studio and create a new project.

create new project in android studio

Select your targeted Android device in the next tab.

target Android devices in android studio

Select Base Activity and click next.

add an activity to your android studio project

Finally, customize the activity.

customize the activity in your Android studio

Adds addiction

To display floating label in the EditText control, we need to add below dependencies.

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:design:25.1.1'
testCompile 'junit:junit:4.12'

Now add EditText and TextInputLayout.

res / layout / content_main.xml

Add EditText to the TextInputLayout you find in android.support.design.widget.TextInputLayout

That’s it!


Now, with the knowledge of adding floating labels to Android apps, you can create forms and login pages. In fact, you can experiment further with different available attributes in the Android Design Support Library. Below we have tried to answer some of the most common questions we have received from our readers:

Frequently asked questions

What is Android Design Support Library?

The Design Support Library enables developers to build on material design components such as navigation drawers, snack bars and tabs.

How to put text in an EditText?

You can enter text in an EditText field by adding the following code:

editText.setText("Hello world!");


How can I reset the error state of EditText?

You can use the following code to do this:







How to change the color of the liquid label?

You can change the color of the floating label from colors.xml.


We hope this guide will help you add a floating label for Edittext using the Design Support Library. If you implement the attributes of the Android Design Library in your startup or business app, it’s best to consult an expert first. Implementation may seem easy, but it is advisable to consult either an expert or a leading Android app development company to make sure it has done the right thing.

You may also like:

This page was last modified on 7 October 2020, at 11:40.

Want to develop Android app from scratch? Contact us now

Get your free consultation now

Source link