Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android EditText view Floating Hint in Material Design

Does API 21 provide a method to use the following feature:

http://www.google.com/design/spec/components/text-fields.html#text-fields-floating-labels

I'm trying to float the EditText hints.

Thanks!

like image 482
xsorifc28 Avatar asked Oct 20 '14 04:10

xsorifc28


People also ask

What is floating hint in android?

Floating Labels: Floating labels first introduced in Android design support library to display floating label over EditText. Firstly it acts as hint in the EditText when the field is empty. After that when a user start inputting the text it starts animating by moving to floating label position.

What is TextInputLayout?

Android App Development for Beginners Before getting into example, we should know what is TextInputLayout in android. TextInputLayout is extended by Linear Layout. It going to act as a wrapper for edit text and shows flatting hint animation for edit text.


2 Answers

Floating hint EditText:

Add below dependency in gradle:

compile 'com.android.support:design:22.2.0' 

In layout:

<android.support.design.widget.TextInputLayout     android:id="@+id/text_input_layout"     android:layout_width="match_parent"     android:layout_height="wrap_content">          <EditText             android:id="@+id/editText"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:hint="UserName"/>     </android.support.design.widget.TextInputLayout> 
like image 186
arpit Avatar answered Sep 20 '22 19:09

arpit


Yes, as of May 29, 2015 this functionality is now provided in the Android Design Support Library

This library includes support for

  • Floating labels
  • Floating action button
  • Snackbar
  • Navigation drawer
  • and more
like image 33
Dave Jensen Avatar answered Sep 21 '22 19:09

Dave Jensen