设计在调用焦点时更改TextInputLayout的标签颜色?

时间:2017-05-26 06:08:25

标签: android android-studio android-textinputlayout

这是我的代码

    emailEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {

                if (!hasFocus) {
                    EditText txtUser = (EditText) v;
                    String userName = txtUser.getText().toString();
                    if (!userName.isEmpty()) {
                        if (!isvaliduser(userName)&&!isValidEmail(userName)) {
                            inputLayoutEmail.setHint("email/snipe id is required to login");
                        }
                    } else {
                        inputLayoutEmail.setHint("email / snipe ID");
//                        inputLayoutEmail.setHintTextAppearance(R.style.hintText);
                    }
                }

            }

        });

我想应用提示颜色。我正在使用set提示外观。但它不能正常工作。提前谢谢。

1 个答案:

答案 0 :(得分:0)

请改用setHintTextColor

inputLayoutEmail.setHintTextColor(ContextCompat.getColor(context,R.color.black));