EditText常用属性

来源:互联网 发布:vue.js pc端ui框架 编辑:程序博客网 时间:2024/06/06 20:12

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="20sp"//大小
android:editable="false" 设置EditText不可编辑

android:capitalize="1573wt"//这样仅允许接受输入1573wt,一般用于密码验证

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"//文字外观

android:drawableBottom  //在text的下方输出一个drawable,如图片。如果指定一个颜色的话会把text的背景设为该颜色,并且同时和background使用时覆盖后者。
android:drawableLeft  //在text的左边输出一个drawable,如图片。
android:drawablePadding  //设置text与drawable(图片)的间隔,与drawableLeft、drawableRight、drawableTop、drawableBottom一起使用,可设置为负数,单独使用没有效果。 
android:drawableRight //在text的右边输出一个drawable,如图片。
android:drawableTop //在text的正上方输出一个drawable,如图片。


参考:链接



0 0