TextInputLayout 和 TextInputEditText 的区别 [英] Difference between TextInputLayout and TextInputEditText
问题描述
需要知道 TextInputEditText 和 TextInputLayout 之间的实际区别,我们应该什么时候使用其中之一.
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.
- TextInputLayout 扩展了 LinearLayout
- TextInputEditText 扩展了 EditText
它们应该一起使用,如下所示:
They were meant to be used together like following:
<TextInputLayout>
<TextInputEditText/>
</TextInputLayout>
官方文档中都有:
TextInputLayout:
https://developer.android.com/reference/android/support/design/widget/TextInputLayout.html
当由于用户输入文本而隐藏提示时,包装 EditText(或后代)以显示浮动标签的布局
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
EditText 的一个特殊子类,用作 TextInputLayout 的子类.
A special sub-class of EditText designed for use as a child of TextInputLayout.
这篇关于TextInputLayout 和 TextInputEditText 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!