当前位置:网站首页>Modify the font size of hint in editext

Modify the font size of hint in editext

2022-04-23 19:08:00 Little brother

modify Hint Font size cannot be in xml Set in , Can only be set in code .

public class HintActivity extends Activity{

   EditText editText;

   @Override
   protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.hint);

   editText=(EditText) findViewById(R.id.editText1);

        SpannableString ss = new SpannableString(" I am a test hint");// Definition hint Value
        AbsoluteSizeSpan ass = new AbsoluteSizeSpan(15,true);// Set font size true Indicates that the unit is sp
        ss.setSpan(ass, 0, ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        editText.setHint(new SpannedString(ss));
   }
}


OK, to be finished .

版权声明
本文为[Little brother]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210601422791.html