Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/222.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 禁用文本输入布局的错误文本提示或更改edittext下划线颜色_Android_Android Edittext_Material Design_Androiddesignsupport - Fatal编程技术网

Android 禁用文本输入布局的错误文本提示或更改edittext下划线颜色

Android 禁用文本输入布局的错误文本提示或更改edittext下划线颜色,android,android-edittext,material-design,androiddesignsupport,Android,Android Edittext,Material Design,Androiddesignsupport,在文本输入布局上设置错误时,是否可以禁用提示。我尝试传入null和一个空字符串,但此时它不会使行变红 我还传入一个带空格的字符串,但如果这样做,则提示仍会占用edittext下划线下的空格 我试图将下划线颜色改为红色,但这似乎需要做很多工作。我现在在API 19上 那么,是否可以禁用该提示 谢谢,所以我认为不可能禁用错误提示(我可能大错特错)。处理此问题的最佳方法是使用setSupportBackgroundTintList或setBackgroundTintList更改editText中行的颜

在文本输入布局上设置错误时,是否可以禁用提示。我尝试传入null和一个空字符串,但此时它不会使行变红

我还传入一个带空格的字符串,但如果这样做,则提示仍会占用edittext下划线下的空格

我试图将下划线颜色改为红色,但这似乎需要做很多工作。我现在在API 19上

那么,是否可以禁用该提示


谢谢

,所以我认为不可能禁用错误提示(我可能大错特错)。处理此问题的最佳方法是使用setSupportBackgroundTintList或setBackgroundTintList更改editText中行的颜色

一些关键的事情

1) 如果您使用的是sdkVersion 23或更高版本,则可以使用常规的editText和setBackgroundTintList方法

2) 如果您介于23-19之间,我认为您也可以在较低的SDKVersion上使用它。您必须在布局中使用Appcompat编辑文本

3) 使用setSupportBackgroundTintList将显示为错误,但这是因为支持库存在错误。您可以在使用它的方法/位置中抑制lint错误

下面是一些代码片段。我希望这能帮助那些只想改变编辑文本中线条颜色的人

我的布局中的AppCompatiEditText

<android.support.design.widget.TextInputLayout
        android:id="@+id/login_user_password_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="16sp"
        android:hint="@string/login_hint_password"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toBottomOf="@id/login_user_email_layout"
        app:layout_constraintBottom_toTopOf="@id/error_text"
        app:layout_constraintRight_toRightOf="parent">

        <android.support.v7.widget.AppCompatEditText
            android:id="@+id/login_user_password"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="textPassword"
            android:imeOptions="actionDone"
            android:layout_marginLeft="30dp"
            android:layout_marginRight="30dp"/>

</android.support.design.widget.TextInputLayout>
绑定是布局,因为我使用的是数据绑定


希望这对某人有所帮助。

是的,可以禁用错误文本并显示带下划线的红线。尽管@huey77答案可能有用,但它很复杂,需要手动控制状态

我的解决方案简单易行,只需将
errorTextAppearance
与0dp配合使用即可:

 <style name="TextError" parent="TextAppearance.AppCompat">
    <item name="android:textSize">0dp</item>
    <item name="android:textColor">?colorError</item>
</style>

<style name="TextInputLayout" parent="Widget.Design.TextInputLayout">
    <item name="errorTextAppearance">@style/TextError</item>
</style>

0dp
?色差
@样式/文本错误
在应用程序主题中:

<item name="textInputStyle">@style/TextInputLayout</item>
@style/TextInputLayout

检查并输入已接受的答案。这可能会对你有所帮助。这是有规律的提示,那些浮在上面的提示。谢谢
<item name="textInputStyle">@style/TextInputLayout</item>