Android更改EditText下划线的颜色样式和动态获取输入的字数的代码教程

2019-09-11| 发布者: admin| 查看: |

通过android:theme属性将此样式应用于您的edittext

 edittext 
 android:layout_width= match_parent 
 android:layout_height= wrap_content 
 android:hint= hint text 
 android:theme= @style/myedittext / 
et_comment.addtextchangedlistener;
 et_comment.setfocusable;
 et_comment.requestfocus;
textwatcher mtextwatcher = new textwatcher {
 private charsequence temp;
 private int editstart;
 private int editend;
 @override
 public void beforetextchanged {
temp = s;
 @override
 public void ontextchanged {
if  = 200) {
 word_remain.settext) + /200 
 @override
 public void aftertextchanged {
editstart = et_comment.getselectionstart;
editend = et_comment.getselectionend;
if  200) {
 toastutil.showtoastshort;
 int tempselection = editstart;
 et_comment.settext;
 et_comment.setselection;
 };