更改 TextInputLayout 的下划线颜色和浮动提示颜色

doe*_*doe 6 android android-styles android-textinputlayout

我在TextInputLayout主题中使用上述属性来使激活时的下划线颜色为绿色TextInputLayout

      <item name="colorControlActivated">#27e905</item>
Run Code Online (Sandbox Code Playgroud)

它工作正常,我得到以下结果

在此输入图像描述

但正如您所看到的,colorControlActivated也会影响浮动提示颜色。我需要不同的颜色来显示浮动提示。有什么办法可以这样做吗?

nik*_*nik 2

在 styles.xml 中添加这些样式

  <style name="textInputLayout.GrayLabel"
    parent="Widget.Design.TextInputLayout">
    <item name="hintTextAppearance">@style/AppTheme.TextFloatLabelAppearance</item>
   </style>

    <style name="AppTheme.TextFloatLabelAppearance"         
     parent="TextAppearance.Design.Hint">
    <!-- Floating label appearance here -->
    <item name="android:textColor">@color/YOUR_COLOR</item>
    <item name="android:textSize">@dimen/YOUR_TEXT_SIZE</item>
</style>
Run Code Online (Sandbox Code Playgroud)

并像这样使用它:-

        <android.support.design.widget.TextInputLayout
            style="@style/textInputLayout.GrayLabel"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/dimen_8dp">
Run Code Online (Sandbox Code Playgroud)