問題描述
我在 TextInputLayout
中使用 EditText
,但是在將支持庫升級到 23.2.0 后,我在 logcat 中收到此警告,這兩者有什么區別一個常規的 EditText
和一個 TextInputEditText
?我似乎找不到任何文檔.
我也在想這個,
橫向 UI 編輯空名稱字段
編輯名稱,您可以看到 IME 不會提示您正在編輯的內容.
橫向 UI 編輯空的描述字段
編輯描述您可以看到 IME 提示您正在編輯的內容.
布局 XML
這兩個字段的區別在于它們的類型EditText
VS TextInputEditText
.這里重要的是 TextInputLayout
有 android:hint
而不是包裝的 EditText,當 TextInputEditText
的幾行Java 代碼有很大的不同.
名稱字段
描述字段
I'm using an EditText
inside a TextInputLayout
, but after upgrading the support library to 23.2.0, I get this warning in the logcat, What's the difference between a regular EditText
and a TextInputEditText
? I can't seem to find any documentation for it.
I was wondering this too, Daniel Wilson gathered the documentation, but to the untrained eye it doesn't mean much. Here's what it's all about: "extract mode" is referring to the type of view that's shown when the space is too small, for example landscape on a phone. I'm using Galaxy S4 with Google Keyboard as input method editor (IME).
Landscape UI without visible IME
Based on the focus (on Description) you can see TextInputLayout
in action pushing the hint outside the editor. Nothing special here, this is what TextInputLayout
is supposed to do.
Landscape UI editing empty Name field
Editing the Name you can see that the IME doesn't give you a hint of what you're editing.
Landscape UI editing empty Description field
Editing the Description you can see that the IME gives you a hint of what you're editing.
Layout XMLs
The difference between the two fields is their type EditText
VS TextInputEditText
. The important thing here is that TextInputLayout
has the android:hint
and not the wrapped EditText, this is the case when TextInputEditText
's few lines of Java code makes a big difference.
Name field
<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>
Description field
<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>
這篇關于添加的 EditText 不是 TextInputEditText.請改用該課程的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!