EditText使用很广泛,今天使用中需要去掉光标以及下划线,还需要点击后隐藏hint

去掉下划线 android:background="@null"
去掉光标 android:cursorVisible="false"

点击后隐藏hint 需要写一个焦点变化事件监听

public View.OnFocusChangeListener onFocusAutoClearHintListener = new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
EditText editText=(EditText)v;
if (!hasFocus) {// 失去焦点
editText.setHint(editText.getTag().toString());
} else {
String hint=editText.getHint().toString();
editText.setTag(hint);
editText.setHint("");
}
}
};

然后再edittext绑定就行了
meditSettingNickName.setOnFocusChangeListener(onFocusAutoClearHintListener);
1
但是在一进入界面edit就会有焦点所以需要把焦点聚集在别的控件上,需要在布局中给EditText的容器控件添加以下两个属性,把焦点聚集在容器控件上。

android:focusable="true"
android:focusableInTouchMode="true"

更多相关文章

  1. android:theme 常用颜色colorPrimary,colorPrimaryDark等属性使
  2. 日期控件Android(安卓)自定义日历控件
  3. 奇葩属性:layout_weight 的解释及使用
  4. Android(安卓)ToggleButton(自定义可滑动的ToggleButton控件)
  5. android pullToRefreshListView的item点击没有反应
  6. Android(安卓)Touch 事件的分发和消费机制
  7. Android开发 常用控件罕见特殊属性集锦
  8. android 让ImageView的图片全屏填充
  9. Android(安卓)调用相册 拍照 实现系统控件缩放 切割图片

随机推荐

  1. Android(安卓)五大布局FrameLayout,Linea
  2. Android(安卓)SDK 安装过程 与 安装失败
  3. Android(安卓)Property Animation动画
  4. Android电源管理简介(下)
  5. Android(安卓)Camera 五 Camera HAL v1
  6. Android(安卓)Design Support Library概
  7. Android(安卓)aapt 资源打包工具
  8. 2011.09.26(3)——— android sample之Note
  9. android 知识点
  10. Android在启动adb时失败解决方案?