Need to know what actually difference between TextInputEditText and TextInputLayout, When should we use one of them.
They are different layouts that complement each other functionalities.
They were meant to be used together like following:
<TextInputLayout>
<TextInputEditText/>
</TextInputLayout>
It's all there on the official docs:
TextInputLayout:
https://developer.android.com/reference/android/support/design/widget/TextInputLayout.html
Layout which wraps an EditText (or descendant) to show a floating label when the hint is hidden due to the user inputting text
TextInputEditText:
https://developer.android.com/reference/android/support/design/widget/TextInputEditText.html
A special sub-class of EditText designed for use as a child of TextInputLayout.
Both TextInputLayout
and TextInputEditText
are different. As mentioned in the documentation Here the TextInputLayout
and TextInputEditText
are meant to be used like the below example(From official doc)
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/form_username"/>
</android.support.design.widget.TextInputLayout>
Also the main difference is when you compare TextInputEditText
with EditText
. The TextInputEditText
provides a hint when when the layout is viewed in landscape mode. This is explained clearly in depth by TWiStErRob. I hope this answers the question. Thank you.
TextInputLayout
must contain a TextInputEditText
instead of the normal EditText
because it designed specially for using inside.
If you add EditText
instead of TextInputEditText
into TextInputLayout
you will get the warning:
EditText added is not a TextInputEditText. Please switch to using that class instead.
For example if you wrap EditText
, in Landscape Mode, you will get a big box, but the hint is missing.
TextInputLayout
has features as floating hints, error labels, character counter, password visibility, animations and their customization