设置可编辑:editText.setFocusable(true);和 editText.setEnabled(true);设置可编辑状态。


设置不可编辑:xml中设置    android:editable="false"

使用editText.setFocusable(false);和editText.setEnabled(false);设置不可编辑状态


editText.setFocusable(false);和editText.setFocusableInTouchMode(false);设置不可编辑状态;

editText.setFocusableInTouchMode(true);editText.setFocusable(true);editText.requestFocus();设置可编辑状态


android:layout_gravity="center_vertical" 设置控件显示的位置:默认top,这里居中显示,还有bottom android:hint="请输入数字!"

设置显示在空间上的提示信息 android:numeric="integer" 设置只能输入整数,如果是小数则是:

decimal android:singleLine="true" 设置单行输入,一旦设置为true,则文字不会自动换行。

android:password="true" 设置只能输入密码

android:textColor = "#ff8c00" 字体颜色

android:textStyle="bold" 字体,bold, italic, bolditalic android:textSize="20dip" 大小

android:capitalize = "characters" 以大写字母写

android:textAlign="center" EditText没有这个属性,但TextView有 android:textColorHighlight="#cccccc" 被选中文字的底色,默认为蓝色

android:textColorHint="#ffff00" 设置提示信息文字的颜色,默认为灰色 android:textScaleX="1.5" 控制字与字之间的间距

android:typeface="monospace" 字型,normal, sans, serif, monospace android:background="@null" 空间背景,这里没有,指透明

android:layout_weight="1" 权重,控制控件之间的地位,在控制控件显示的大小时蛮有用的。

android:textAppearance="?android:attr/textAppearanceLargeInverse" 文字外观,这里引用的是系统自带的一个外观,?表示系统是否有这种外观,否则使用默认的外观。不知道这样理解对不对? 通过EditText的layout xml文件中的相关属性来实现:

1. 密码框属性 android:password="true" 这条可以让EditText显示的内容自动为星号,输入时内容会在1秒内变成*字样。

2. 纯数字 android:numeric="true" 这条可以让输入法自动变为数字输入键盘,同时仅允许0-9的数字输入

3. 仅允许 android:capitalize="cwj1987" 这样仅允许接受输入cwj1987,一般用于密码验证 下面是一些扩展的风格属性

android:editable="false" 设置EditText不可编辑

android:singleLine="true" 强制输入的内容在单行

android:ellipsize="end" 自动隐藏尾部溢出数据,一般用于文字内容过长一行无法全部显示时







更多相关文章

  1. Android(安卓)简单实现自定义进度条
  2. ConstraintLayout (约束布局)属性详情
  3. 三十一、关于android camera setParameters出错
  4. Android的Notification的简介-android学习之旅(四十一)
  5. Android使用Intent启动Service的Intent必须是显式的
  6. 修正android cocos2dx项目当点击属性时提示错误的问题
  7. Android中的android.provider.Settings.System系统属性设定
  8. 创建ListView的基本步骤
  9. 【Android】魅族Flyme OS 3摄像头无法预览的问题

随机推荐

  1. 最近用到的SQL语句
  2. QT5.3连接mysql数据库
  3. postgresql 数组 多了引号 空格处理
  4. 解决缺少sql头文件编译错误
  5. (SqlServer)分离所有用户数据库
  6. python3爬虫爬取豆瓣电影并保存到sql ser
  7. Spark RDD算子/SparkSQL分别实现对电影数
  8. SQL中带闭包表的有向循环图
  9. CentOS下mysql启动失败
  10. Sqlserver 链接服务器和同义词