Android TextInputLayout的setTextColor等效项

Android TextInputLayout的setTextColor等效项,android,textinputlayout,Android,Textinputlayout,我正在使用TextInput布局创建一个文本输入框。我想根据输入框的不同变体应用可绘制和颜色资源。 我在res/color和res/drawable目录下创建了不同的xml资源文件 public enum InputTextVariant { Standard, Stepper, MultiLine; } public void setVariant(int variantParam) { Drawable d; ColorStateList csl;

我正在使用TextInput布局创建一个文本输入框。我想根据输入框的不同变体应用可绘制和颜色资源。 我在res/color和res/drawable目录下创建了不同的xml资源文件

public enum InputTextVariant {
    Standard, Stepper, MultiLine;
}
 public void setVariant(int variantParam) {
        Drawable d;
        ColorStateList csl;
        InputTextVariant variant = SpectrumInputTextVariant.values()[variantParam];
        switch (variant) {
            case Standard:
                csl = AppCompatResources.getColorStateList(getContext(), R.color.textcolor_btn_cta);
                d = AppCompatResources.getDrawable(getContext(), R.drawable.btn_cta_material);
                //setTextColor(csl);
                setBackgroundTintList(csl);
                setBackground(d);
我想为按钮使用类似于setTextColor的东西。 我为不同的状态(禁用、悬停、聚焦等)指定了不同的颜色和形状。 如何加载此TextInputLayout的颜色资源。
我已经尝试过挫败groundtint,它需要API版本>=21。但我还需要支持较低版本。

您可以在可绘制级别管理色调:

Drawable d = AppCompatResources.getDrawable(...);
ColorStateList csl = AppCompatResources.getColorStateList(...);
d = DrawableCompat.wrap(d);
DrawableCompat.setTintList(csl);
setBackground(d);