常用的属性:

显示密码

通过设置EditText的setTransformationMethod()方法来实现隐藏密码或这显示密码。

editText.setTransformationMethod(PasswordTransformationMethod.getInstance());//设置密码为不可见。

android:typeface="monospace" 字形有:normal, sans, serif,monospace
android:editable 是否可编辑

键盘弹出

//不自动弹出键盘

<activity android:name=".AddLinkman"android:windowSoftInputMode="adjustUnspecified|stateHidden"/>

 

//关闭键盘(比如输入结束后执行)

InputMethodManager imm =(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);

imm.hideSoftInputFromWindow(etEditText.getWindowToken(), 0);

 

//自动弹出键盘,让EditText获得焦点,但是获得焦点并不会自动弹出键盘

((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE))

.toggleSoftInput(0,InputMethodManager.HIDE_NOT_ALWAYS);

etEditText.requestFocus();

android:imeOptinos 回车键的类型和选项,如 flagNoExtractUi 当屏幕足够时,不显示回车键。
android:digits="123abcde" 只能输入123abcde,其它输入不进去。
android:windowSoftInputMode

这是Activity的属性。软键盘的调起导致原来的界面被挤上去,或者导致界面下面的tab导航被挤上去。

使用Manifest中的Activity的android:windowSoftInputMode的"adjustPan"属性。

另外注意: 有关软键盘的问题可参考android:windowSoftInputMode中属性。

edittext光标详解

//让光标放入到点击位置。

edittext.requestFocusFromTouch();

 

//默认方式获得焦点

edittext.requestFocus();

//光标处插入

EditText editor = (EditText)getCurrentView();

int cursor = editor.getSelectionStart();

editor.getText().insert(cursor,delta);

android:cursorVisible="false"  隐藏光标

 

相关文章:

  • 2021-12-13
  • 2022-12-23
  • 2021-07-30
  • 2021-11-13
  • 2021-09-25
  • 2022-01-04
  • 2021-06-04
猜你喜欢
  • 2021-09-02
  • 2021-06-27
  • 2022-12-23
  • 2021-12-21
相关资源
相似解决方案