Floating Label in EditText Material Design Android

Hello Friends,

This tutorial is about Floating Label (Like OLX android App) in Material design. Before Material design When user Tap on EditText then hint of editText was gone. But with the help of TextInputLayout  hint text will move to top of EditText. First of all create new project in Android Studio.

1. After creating project open build.gradle(Module:app).
2. Add appCompact-v7 and design dependencies in build.gradle.

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:design:22.2.0'
}


3. Add EditText within TextInputLayout. 


    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Email" />
    </android.support.design.widget.TextInputLayout>


Some important points: 
1. TextInputLayout contains only one EditText. 
2. don't forgot to add dependency 'com.android.support:design:23.1.1'.


References : 
1. https://developer.android.com/reference/android/support/design/widget/TextInputLayout.html

Screenshots 


Source Code link:-  Code

Happy Blogging !! :D

Comments

Post a Comment

Popular posts from this blog

How to combine two Bitmap in Android

How to change the color of Hamburger icon in Toolbar Android

How to do Facebook Login with Custom Button Android