Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OutlinedBox for TextInputEditText is not working

I am working on login screen where I want to implememt material edit text with following view :

enter image description here

Following is my code :

<com.google.android.material.textfield.TextInputLayout
        android:layout_width="match_parent"
        style="@style/ThemeOverlay.MaterialComponents.TextInputEditText.OutlinedBox"
        android:layout_height="wrap_content">

        <com.google.android.material.textfield.TextInputEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="This is Hint"/>

    </com.google.android.material.textfield.TextInputLayout>

But OutlinedBox is not appearing. This is how it looks :

enter image description here

PLease help.

like image 687
Ganesh Ghodake Avatar asked Nov 20 '18 08:11

Ganesh Ghodake


People also ask

What is Text Input layout in android Studio?

The primary use of a TextInputLayout is to act as a wrapper for EditText(or its descendant) and enable floating hint animations. Rule of Thumb : TextInputLayout should wrap TextInputEditText instead of the normal EditText.


1 Answers

Use this

style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"

Instead pf this

style="@style/ThemeOverlay.MaterialComponents.TextInputEditText.OutlinedBox"

SAMPLE CODE

<com.google.android.material.textfield.TextInputLayout
    android:layout_width="match_parent"
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    android:layout_height="wrap_content">

    <com.google.android.material.textfield.TextInputEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="This is Hint"/>

</com.google.android.material.textfield.TextInputLayout>

OUTPUT enter image description here

like image 62
AskNilesh Avatar answered Sep 28 '22 10:09

AskNilesh