Android UI详解之EditText
来源:互联网 发布:淘宝边度阳光是正品吗 编辑:程序博客网 时间:2024/06/06 04:19
Android UI详解之EditText
一、EditText 属性
EditText继承关系:View-->TextView-->EditText。
1、android:layout_gravity="center_vertical" ----- 设置控件显示的位置:默认top,这里居中显示还有bottom
2、android:hint="请输入数字!" ----- 设置显示在空间上的提示信息
3、android:numeric="integer" -----设置只能输入整数,如果是小数则是:decimal
4、android:singleLine="true" -----设置单行输入,一旦设置为true,则文字不会自动换行。
5、android:password="true" ------设置只能输入密码
6、android:textColor = "#ff8c00" ----字体颜色
7、android:textStyle="bold" ----字体,bold, italic, bolditalic
8、android:textSize="20dip" -----设置字体大写 ,大 小
10、android:capitalize = "characters" -----以大写字母写
11、android:textAlign="center" -----EditText没有这个属性,但TextView有,居中
12、android:textColorHighlight="#cccccc" -----被选中文字的底色,默认为蓝色
13、android:textColorHint="#ffff00" --------设置提 示信息文字的颜色,默认为灰色
14、android:textScaleX="1.5" -----控制字与字之间的间距
15、android:typeface="monospace" ------字型,normal, sans, serif, monospace
16、android:background="@null" -----空间背景,这里没有,指透明
17、android:layout_weight="1" -----权重,控制控件之间的 地位,在控制控件显示的大小时蛮有用的。
1.让EditText默认不弹出软件键盘
方法一:
在 AndroidMainfest.xml中选择哪个activity,设置windowSoftInputMode属性为 adjustUnspecified|stateHidden
例如:<activity android:name=".Main"
android:label="@string/app_name"
android:windowSoftInputMode="adjustUnspecified|stateHidden"
android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
方法二:
让 EditText失去焦点,使用EditText的clearFocus方法
例如:EditText edit=(EditText)findViewById(R.id.edit);
edit.clearFocus();
方 法三:
强制隐藏Android输入法窗口
例如:EditText edit=(EditText)findViewById(R.id.edit);
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edit.getWindowToken(),0);
- Android UI详解之EditText
- Android UI(EditText)详解
- Android UI学习之EditText
- Android UI控件详解-EditText(编辑框)
- Android的UI组件之TextView、EditText
- Android UI之EditText注意点收集
- Android控件详解之EditText
- Android之EditText属性详解
- android ui EditText
- Android UI, EditText, AutoCompleteTextView
- edittext Android ui优化
- Android软件开发之EditText 详解
- Android软件开发之EditText 详解
- Android开发之EditText属性详解
- Android开发之EditText属性详解
- Android开发之EditText属性详解
- Android开发之EditText属性详解
- Android开发之EditText属性详解
- 正则表达式语法
- HiveQL 数据定义语言使用(一)—Hive中数据库的创建、显示、删除和修改操作介绍
- 排序算法总结
- scala入门-01-IDEA安装scala插件
- opencv第一个显示图像的小程序
- Android UI详解之EditText
- svn常用命令
- 不良代码展示-Activity中使用线程的例子
- LitePal学习小结 (一)
- ScheduledExecutorService定时周期执行指定的任务
- SC16IS740 Block diagram
- 关于下载文件封装的两个类(Mars)
- Python实现约瑟夫问题
- android异步线程