更改 TextInputLayout 轮廓颜色 [英] Change the TextInputLayout outline color

查看:60
本文介绍了更改 TextInputLayout 轮廓颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用材质样式自定义 TextInputLayout.我设法将聚焦状态设置为我想要的颜色:

I'm trying to customize a TextInputLayout with material style. I managed to set the focused state to the colors I want:

使用

<com.google.android.material.textfield.TextInputLayout
     style="@style/LoginTextInputLayoutStyle"
     android:theme="@style/LoginTextInputLayoutStyle"
     android:textColorHint="#fff"
     app:boxStrokeColor="#fff"
     .....>
          <EditText ...

风格在哪里:

<style name="LoginTextInputLayoutStyle" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense">
    <item name="colorAccent">#fff</item>
</style>   

但是当 textinput 没有被聚焦时,我会看到这个:

But when the textinput is not focused I get this look:

如何将黑线的颜色也改为白色?

How can I change the color of the black line to be white too?

推荐答案

使用此样式来应用边框颜色和边框宽度,如下所示:

Use this style to apply border color and border width like this :

<style name="LoginTextInputLayoutStyle" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense">
    <item name="boxStrokeColor">#fff</item>
    <item name="boxStrokeWidth">2dp</item>
</style>

从此链接

在您的 colors.xml 文件中添加以下行以覆盖 TextInputLayout

Add below line in your colors.xml file that overrides default color for TextInputLayout

<color name="mtrl_textinput_default_box_stroke_color" tools:override="true">#fff</color>

这篇关于更改 TextInputLayout 轮廓颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆