我在 TextInputLayout
中使用 EditText
,但是在将支持库升级到 23.2.0 后,我在 logcat 中收到此警告,这两者有什么区别一个常规的 EditText
和一个 TextInputEditText
?我似乎找不到任何文档。
最佳答案
我也想知道,Daniel Wilson收集了文档,但对于未经训练的人来说,这并不意味着什么。以下是全部内容:"extract mode"指的是空间太小时显示的 View 类型,例如手机上的风景。我正在使用 Galaxy S4 和 Google 键盘作为输入法编辑器 (IME)。
没有可见 IME 的横向 UI
基于焦点(在描述上),您可以看到 TextInputLayout
正在将提示推送到编辑器之外。这里没什么特别的,这是 TextInputLayout
应该做的。
横向 UI 编辑空名称字段
编辑名称,您可以看到 IME 不会提示您正在编辑的内容。
横向 UI 编辑空的描述字段
编辑描述您可以看到 IME 提示您正在编辑的内容。
布局 XML
这两个字段的区别在于它们的类型EditText
VS TextInputEditText
。这里重要的是 TextInputLayout
有 android:hint
而不是包装的 EditText,当 TextInputEditText
的几行Java 代码有很大的不同。
名称字段
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Item Name"
>
<EditText
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</android.support.design.widget.TextInputLayout>
描述字段
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Item Description"
>
<android.support.design.widget.TextInputEditText
android:id="@+id/description"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:minLines="4"
android:scrollbars="vertical"
/>
</android.support.design.widget.TextInputLayout>
关于android - 添加的 EditText 不是 TextInputEditText。请改用该类(class),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35775919/