簡體   English   中英

如何以編程方式根據特定條件更改 TextInputLayout 的焦點提示顏色(上)

[英]How to change the focused hint color(upper) of TextInputLayout according to specific conditions programmatically

在此處輸入圖像描述

如果在 TextInputLayout 中輸入的文本符合 email 正則表達式,我想以編程方式更改附圖中顯示的提示 label 的顏色。

您可以使用TextInputLayoutsetHintTextColor function 根據您的喜好以編程方式更改提示顏色。

TextInputLayout textInputLayout = findViewById(R.id.textInputLayout);  

int colorInt = getResources().getColor(R.color.red,getTheme());
ColorStateList colorStateList = ColorStateList.valueOf(colorInt);

textInputLayout.setHintTextColor(colorStateList);

這將改變提示 label 顏色,如下所示:

文本輸入布局

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM