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

查看:309
本文介绍了更改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. Thanks

推荐答案

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

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天全站免登陆