【问题标题】:How to change underline color error textinputlayout android如何更改下划线颜色错误textinputlayout android
【发布时间】:2020-05-12 17:01:53
【问题描述】:

我想知道如何更改TextInputLayout下划线的错误颜色。

【问题讨论】:

    标签: android android-textinputlayout material-components-android


    【解决方案1】:

    只需使用app:boxStrokeErrorColor 属性:

        <com.google.android.material.textfield.TextInputLayout
            app:boxStrokeErrorColor="@color/primaryLightColor"
            ...>
    

    它需要 Material Components 库版本1.2.0

    【讨论】:

      【解决方案2】:

      您可以像这样更改edittext背景中的颜色。这个背景使下划线消失。但是你可以把它做成你想要的任何颜色。

      <android.support.design.widget.TextInputLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_margin="@dimen/activity_horizontal_margin"
                  app:hintEnabled="false">
      
                  <android.support.design.widget.TextInputEditText
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:hint="Floating Hint Disabled"
                      android:background="@android:color/transparent" />
      
              </android.support.design.widget.TextInputLayout
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-09-15
        • 2018-09-11
        • 1970-01-01
        • 2011-12-02
        • 2021-03-10
        • 2020-09-09
        • 1970-01-01
        相关资源
        最近更新 更多