Google has introduced a new support library called android design support library. This library includes some new components including navigation drawer views, floating action buttons, snackbar, tabs, floating labels for editing text, etc. In this example, I will show you to apply the android floating label to EditText using the design support library.
Create a new Android Project
Now, we are going to create a new android project to implement a floating label for editing text in android apps using the design support library. Create a new android project with the following information.
App Name: Floating Label for EditText
Company Domain: viralandroid.com
Package Name: com.viralandroid.floatinglabelsforedittext
Minimal SDK: Android 2.2 (API 8 Froyo)
Floating Labels for EditText Floating DemoLabel
Add support for android library design support in your build.gradle file.
Added EditText and TextInputLayout
Open your xml layout file and add the code below.
res / layout / edit_text_activity.xml
Add the following string value to your strings.xml file.
res / values / strings.xml
And following is the default code ofactivity file.