2
我正在使用TextInput佈局創建文本輸入框。我想根據輸入框的不同變體應用drawable和color資源。 我已經在res/color和res/drawable目錄下創建了不同的xml資源文件。setTextColor等同於TextInputLayout
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的顏色資源。 我試圖setBackgroundTint需要API版本> = 21。但我還需要支持較低版本。