禁用/删除TextInputLayout XML中的浮动标签提示文本 [英] Disable/Remove floating label hint text in TextInputLayout XML
问题描述
这似乎违反直觉,但是有没有办法禁用或删除 TextInputLayout
中的浮动标签提示?我要使用 TextInputLayout
而不是仅仅使用 EditText
的原因是 TextInputLayout
提供的计数器.
This may seem counter-intuitive but is there a way to disable or remove the floating label hint in TextInputLayout
? The reason I want to use TextInputLayout
instead of just an EditText
is for the counter that TextInputLayout
provides.
这是我到目前为止所拥有的:
Here is what I have so far:
<android.support.design.widget.TextInputLayout
android:id="@+id/textContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
app:counterEnabled="true"
app:counterMaxLength="100">
<EditText
android:id="@+id/myEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top|left"
android:inputType="textMultiLine|textCapSentences"
android:maxLength="100"
android:scrollbars="vertical"
android:hint="This is my cool hint"/>
</android.support.design.widget.TextInputLayout>
推荐答案
您可以调用的支持库版本23.2.0开始
Starting version 23.2.0 of the Support Library you can call
setHintEnabled(false)
或将其放在您的TextInputLayout xml中:
or putting it in your TextInputLayout xml as such :
app:hintEnabled="false"
尽管该名称可能使您认为它删除了所有提示,但它仅删除了浮动提示.
Though the name might makes you think it removes all hints, it just removes the floating one.
https://code.google.com/p/android/issue/detail?id = 181590
这篇关于禁用/删除TextInputLayout XML中的浮动标签提示文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!