先看效果:

代码:

[html] view plain copy print ?
  1. <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     xmlns:tools="http://schemas.android.com/tools"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="match_parent" >  
  5.   
  6.     <RelativeLayout  
  7.         android:layout_width="match_parent"  
  8.         android:layout_height="match_parent" >  
  9.   
  10.         <TextView  
  11.             android:id="@+id/tip1"  
  12.             android:layout_width="wrap_content"  
  13.             android:layout_height="wrap_content"  
  14.             android:text="1.设置一个空白提示文本: android:hint=www.wirelessqa.com; " />  
  15.   
  16.         <TextView  
  17.             android:id="@+id/tip2"  
  18.             android:layout_width="wrap_content"  
  19.             android:layout_height="wrap_content"  
  20.             android:layout_below="@+id/tip1"  
  21.             android:text="2.设置只允许输入长度不超过4个的字符: android:maxLength=4;" />  
  22.   
  23.         <EditText  
  24.             android:id="@+id/edit_tip"  
  25.             android:layout_width="fill_parent"  
  26.             android:layout_height="40dp"  
  27.             android:layout_below="@+id/tip2"  
  28.             android:hint="www.wirelessqa.com"  
  29.             android:maxLength="4" />  
  30.   
  31.         <TextView  
  32.             android:id="@+id/tip3"  
  33.             android:layout_width="wrap_content"  
  34.             android:layout_height="wrap_content"  
  35.             android:layout_below="@+id/edit_tip"  
  36.             android:text="3.设置空白提示文本的颜色:android:textColorHint=#FF0000; " />  
  37.   
  38.         <EditText  
  39.             android:id="@+id/edit_tip2"  
  40.             android:layout_width="fill_parent"  
  41.             android:layout_height="40dp"  
  42.             android:layout_below="@+id/tip3"  
  43.             android:hint="www.wirelessqa.com"  
  44.             android:textColorHint="#FF0000" />  
  45.   
  46.         <TextView  
  47.             android:id="@+id/tip4"  
  48.             android:layout_width="wrap_content"  
  49.             android:layout_height="wrap_content"  
  50.             android:layout_below="@+id/edit_tip2"  
  51.             android:text="4.设置edittext为不可用:  android:enabled=false " />  
  52.   
  53.         <EditText  
  54.             android:id="@+id/edit_tip3"  
  55.             android:layout_width="fill_parent"  
  56.             android:layout_height="40dp"  
  57.             android:layout_below="@+id/tip4"  
  58.             android:enabled="false"  
  59.             android:hint="www.wirelessqa.com"  
  60.             android:textColorHint="#EEB422" />  
  61.   
  62.         <TextView  
  63.             android:id="@+id/tip5"  
  64.             android:layout_width="wrap_content"  
  65.             android:layout_height="wrap_content"  
  66.             android:layout_below="@+id/edit_tip3"  
  67.             android:text="5.设置edittext为不可编缉:  android:editable=false " />  
  68.   
  69.         <EditText  
  70.             android:id="@+id/edit_tip4"  
  71.             android:layout_width="fill_parent"  
  72.             android:layout_height="40dp"  
  73.             android:layout_below="@+id/tip5"  
  74.             android:editable="false"  
  75.             android:hint="www.wirelessqa.com"  
  76.             android:textColorHint="#EEB422" />  
  77.   
  78.         <TextView  
  79.             android:id="@+id/tip6"  
  80.             android:layout_width="wrap_content"  
  81.             android:layout_height="wrap_content"  
  82.             android:layout_below="@+id/edit_tip4"  
  83.             android:text="6.设置edittext为文本域" />  
  84.   
  85.         <EditText  
  86.             android:id="@+id/edit_tip5"  
  87.             android:layout_width="fill_parent"  
  88.             android:layout_height="100dp"  
  89.             android:layout_below="@+id/tip6" />  
  90.   
  91.         <TextView  
  92.             android:id="@+id/tip7"  
  93.             android:layout_width="wrap_content"  
  94.             android:layout_height="wrap_content"  
  95.             android:layout_below="@+id/edit_tip5"  
  96.             android:text="7.设置输入特殊字符 - 密码: android:password=true" />  
  97.   
  98.         <EditText  
  99.             android:id="@+id/edit_tip6"  
  100.             android:layout_width="fill_parent"  
  101.             android:layout_height="40dp"  
  102.             android:layout_below="@+id/tip7"  
  103.             android:password="true" />  
  104.   
  105.         <TextView  
  106.             android:id="@+id/tip8"  
  107.             android:layout_width="wrap_content"  
  108.             android:layout_height="wrap_content"  
  109.             android:layout_below="@+id/edit_tip6"  
  110.             android:text="8.设置输入特殊字符 - 电话号码: android:phoneNumber=true" />  
  111.   
  112.         <EditText  
  113.             android:id="@+id/edit_tip7"  
  114.             android:layout_width="fill_parent"  
  115.             android:layout_height="40dp"  
  116.             android:layout_below="@+id/tip8"  
  117.             android:phoneNumber="true" />  
  118.   
  119.         <TextView  
  120.             android:id="@+id/t9"  
  121.             android:layout_width="wrap_content"  
  122.             android:layout_height="wrap_content"  
  123.             android:layout_below="@+id/edit_tip7"  
  124.             android:text="9.设置输入数字类型 - integer(正整数): android:numeric=integer" />  
  125.   
  126.         <EditText  
  127.             android:id="@+id/e9"  
  128.             android:layout_width="fill_parent"  
  129.             android:layout_height="40dp"  
  130.             android:layout_below="@+id/t9"  
  131.             android:numeric="integer" />  
  132.          <TextView  
  133.             android:id="@+id/t10"  
  134.             android:layout_width="wrap_content"  
  135.             android:layout_height="wrap_content"  
  136.             android:layout_below="@+id/e9"  
  137.             android:text="10.设置输入数字类型 - isigned(带符号整数): android:numeric=signed" />  
  138.   
  139.         <EditText  
  140.             android:id="@+id/e10"  
  141.             android:layout_width="fill_parent"  
  142.             android:layout_height="40dp"  
  143.             android:layout_below="@+id/t10"  
  144.             android:numeric="signed" />  
  145.         <TextView  
  146.             android:id="@+id/t11"  
  147.             android:layout_width="wrap_content"  
  148.             android:layout_height="wrap_content"  
  149.             android:layout_below="@+id/e10"  
  150.             android:text="11.设置输入数字类型 - decimal(浮点数): android:numeric=decimal" />  
  151.   
  152.         <EditText  
  153.             android:id="@+id/e11"  
  154.             android:layout_width="fill_parent"  
  155.             android:layout_height="40dp"  
  156.             android:layout_below="@+id/t11"  
  157.             android:numeric="decimal" />      
  158.     RelativeLayout>  
  159.   
  160. ScrollView>  
                                                                                                                                                                                     


本文链接: 【Android常用控件】EditText常用属性【一】:空白提示/文本域/特殊字符/数字类型/等属性设置

转载声明:本站文章若无特别说明,皆为原创,转载请注明来源:WirelessQA,谢谢!^^


补充edittext中文api文档:http://www.cnblogs.com/over140/archive/2010/09/02/1815439.html

更多相关文章

  1. Android(安卓)设置全屏和无标题模式
  2. Android开发学习笔记——对话框Dialog
  3. Text控件运用小收集
  4. Android(安卓)Studio和SDK的下载安装以及个性化设置方法
  5. android手写输入
  6. android usb解析(一)UsbDeviceManager(and5.1)
  7. GrideView简单使用
  8. ActionBar使用
  9. Android(安卓)Action Bar学习(一)--基本介绍及使用

随机推荐

  1. Android(安卓)简单数据库(增删改查)
  2. android 注册、登录实现
  3. android进度条对话框
  4. android 命令珍藏
  5. Android(安卓)UI控件详解-Button(按钮)点
  6. 遍历android根目录的简单资源查看器
  7. android 工具类2
  8. Android(安卓)JSON 解析
  9. Android轻量级JSON操作类
  10. Android(安卓)图片转成String保存