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

  • Problem with basic access authentication in file downloader
  • admob: app crashes on android 3.2
  • Textview on(above) Button, doesn't work in Android 5(API 21)
  • Is there any way to put an EditText/input field into a homescreen widget?
  • prevent partial overlapping of shape drawable stroke
  • Avoiding data loss due to interruption when saving files on android?
  • I’m trying to float the EditText hints.

    Thanks!

    Related posts:

    Android HttpsUrlConnection eofexception
    Android and HDMI CEC
    Hide status bar android
    Android NDK: load_library: cannot locate srand
    Change text color in android.R.layout.simple_list_item_2
    How to convert .cer to BKS
  • How does density value calculate in android
  • How to use Fragments in Android
  • Duplicate Files copied in APK META-INF when Gradle building
  • Android AutoCompleteTextView with Custom Adapter filtering not working
  • Is there a documentation standard for custom XML style attributes in Android?
  • QR code scanning without fullscreen camera
  • 8 Solutions collect form web for “Android EditText view Floating Hint in Material Design”

    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>
    

    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

    The Android support library can be imported within gradle in the dependencies :

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

    It should be included within GradlePlease! And as an example to use it:

     <android.support.design.widget.TextInputLayout
        android:id="@+id/to_text_input_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    
        <AutoCompleteTextView
            android:id="@+id/autoCompleteTextViewTo"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:hint="To"
            android:layout_marginTop="45dp"
            />
    </android.support.design.widget.TextInputLayout>
    

    Btw, the editor may not understand that AutoCompleteTextView is allowed within TextInputLayout.

    Android hasn’t provided a native method. Nor the AppCompat.

    Try this library: https://github.com/rengwuxian/MaterialEditText

    This might be what you want.

    Import the Support Libraries, In your project’s build.gradle file, add the following lines in the project’s dependencies:

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

    Use following TextInputLayout in your UI Layout:

    <android.support.design.widget.TextInputLayout
        android:id="@+id/usernameWrapper"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    
        <EditText
            android:id="@+id/username"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="textEmailAddress"
            android:hint="Username"/>
    
    </android.support.design.widget.TextInputLayout>
    

    Than, call setHint on TextInputLayout just after setContentView call because, to animate the floating label, you just need to set a hint, using the setHint method.

    final TextInputLayout usernameWrapper = (TextInputLayout) findViewById(R.id.usernameWrapper);
    usernameWrapper.setHint("Username");
    

    @andruboy’s suggestion of https://gist.github.com/chrisbanes/11247418 is probably your best bet.

    https://github.com/thebnich/FloatingHintEditText kind of works with appcompat-v7 v21.0.0, but since v21.0.0 does not support accent colors with subclasses of EditText, the underline of the FloatingHintEditText will be the default solid black or white. Also the padding is not optimized for the Material style EditText, so you may need to adjust it.

    No it doesn’t. I would expect this in a future api release, but for now we are stuck with EditText. Another option is this library:
    https://github.com/marvinlabs/android-floatinglabel-widgets

    Try this way

    enter image description here

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

    }

    for more reference click here

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.