简体   繁体   English

如何更改 TextInputEditText 中的默认下划线颜色

[英]How change default underline color in TextInputEditText

my underline color in editText is primaryColor, I want to change it to another when it is out of focus.我在editText中的下划线颜色是primaryColor,我想在它失焦时将其更改为另一种颜色。

xml xml

<com.google.android.material.textfield.TextInputLayout
            android:id="@+id/usernameInputLayout"
            android:layout_width="384dp"
            android:layout_height="75dp"
            android:layout_marginStart="16dp"
            android:layout_marginTop="200dp"
            android:layout_marginEnd="16dp"
            android:hint="@string/username_hint"
            app:hintTextColor="@color/white"
            android:textColorHint="@color/white"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

            <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/usernameInputEditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="text"
                android:textColor="@color/white"
                android:background="@color/primaryColor"
                android:text="@={authViewModel._username}"/>
        </com.google.android.material.textfield.TextInputLayout>

i tried我试过了

app:boxStrokeColor="color/blue" 

but it works when editText is focused, in other word user is in editText, I want to when user isn't in editText line was blue and when user is in editText line should be white但是当editText被聚焦时它可以工作,换句话说用户在editText中,我想当用户不在editText行是蓝色的,当用户在editText行应该是白色的

Please add this line to your edittext请将此行添加到您的编辑文本中

android:backgroundTint="@color/colorWhite"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM