change font for editText hint

后端 未结 10 2373
野趣味
野趣味 2020-12-03 13:17

Is it possible to change the font for the hint displayed in the EditText field? I want to set the font in the xml itself.

10条回答
  •  时光取名叫无心
    2020-12-03 14:16

    I haven't find out any useful way to change hint font in XML.But you can achieve like this:

    mEt.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    
        }
    
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if(s.length()== 0) {
                //mEt.setTypeFace(normalFont);
            }else{
               // mEt.setTypeFace(hintFont);
            }
        }
    
        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    

提交回复
热议问题