err eight ole ase string num nco enter
- 1.在edittext编辑框中调用属性。
- android: layout_width = "match_parent"android: layout_height = "50dp"android: paddingLeft = "5dp"android: layout_marginRight = "30dp"android: background = "@null"android: textColorHint = "@android:color/white" // 提示文字颜色设置
- android: textCursorDrawable = "@drawable/cursor" // 光标颜色、大小等设置
- android: gravity = "center_vertical"android: hint = "@string/hint_phone_number"android: singleLine = "true" / >
- 2.创建一个drawable资源文件来设置,也可以直接用颜色设置。
- android: color = "@android:color/white" >
- 3.监听edittext的焦点变化,获得焦点时将光标设置到最后的位置;
- @Override public void onFocusChange(View v, boolean hasFocus) {
- switch (v.getId()) {
- case R.id.user_name_or_phone_number:
- if (hasFocus) {
- String content = userName.getText().toString(); //获取编辑框的内容
- userName.setSelection(content.length()); // 将光标设置的最后的位置
- }
- break;
- }
- }
光标设置、hint 设置
来源: http://www.bubuko.com/infodetail-2212851.html