android – 更改TextInputLayout轮廓颜色

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

运用

<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没有聚焦时,我得到了这样的表情:

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

解决方法

使用此样式应用边框颜色和边框宽度,如下所示:
<style name="LoginTextInputLayoutStyle" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense">
    <item name="boxStrokeColor">#fff</item>
    <item name="boxStrokeWidth">2dp</item>
</style>

从这个link获取有关样式的其他详细信息

在colors.xml文件中添加以下行,该文件将覆盖TextInputLayout的默认颜色

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

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...