android一些控键的属性
2016-05-30 15:24
357 查看
TextView
android:ems = “5” 设置TextView的宽度为N个字符的宽度。
android:lines= “2” 设置文本的行数,设置两行就显示两行,即使第二行没有数据。
android:textColor = “#ff00ff” 设置文本颜色
android:textSize = “15sp” 设置文字大小,推荐度量单位”sp”,如”15sp”
android:textStyle =”bold” 设置字形[bold(粗体) 0, italic(斜体) 1, bolditalic(又粗又斜) 2] 可以设置一个或多个,用“|”隔开
android:typeface = “normal ” 设置文本字体,必须是以下常量值之一:normal 0, sans 1, serif 2, monospace(等宽字体) 3]
android:lineSpacingExtra = “10sp”设置行间距。
android:textScaleX = “1.2”设置文字X轴的比例。
EditText
android:hint=”请输入数字!”//设置显示在空间上的提示信息
android:textColorHint=”#ffff00”//设置提示信息文字的颜色,默认为灰色
android:singleLine=”true”//设置单行输入,一旦设置为true,则文字不会自动换行。
android:password=”true”//设置只能输入密码
android:background=”@null”//背景,可以是图片,也可以是纯色,这里没有,指透明
android:cursorVisible=“true”设定光标为显示/隐藏,默认显示
android:gravity=”center”设置文本位置,如设置成“center”,文本将居中显示。
ImageView
ImageView控键的使用
android:src=”@drawable/ic_launcher22”
(1)drawable-hdpi对应 (480x800)(480x854)
(2)drawable-mdpi对应 (320x480)
(3)drawable-ldpi对应 (240x320)
(4)drawable-xdpi对应 (720x1280)
(5)drawable-xxdpi对应(1080x1800)
CheckBox
如题复选框,即可以同时选中多个选项,至于获得选中的值,同样有两种方式:
1.为每个CheckBox添加事件:setOnCheckedChangeListener
2.弄一个按钮,在点击后,对每个checkbox进行判断:isChecked();
1,android:checked=”true”
2,isChecked
RadioButton
此处转载引用于:http://hualang.iteye.com/blog/964507
网址中有详细的例子介绍
RadioButton和RadioGroup配合使用
RadioButton的单选按钮;
RadioGroup是单选组合框,用于将RadioButton框起来;
在没有RadioGroup的情况下,RadioButton可以全部都选中;
当多个RadioButton被RadioGroup包含的情况下,RadioButton只可以选择一个;
注意:单选按钮的事件监听用setOnCheckedChangeListener来对单选按钮进行监听
android:ems = “5” 设置TextView的宽度为N个字符的宽度。
android:lines= “2” 设置文本的行数,设置两行就显示两行,即使第二行没有数据。
android:textColor = “#ff00ff” 设置文本颜色
android:textSize = “15sp” 设置文字大小,推荐度量单位”sp”,如”15sp”
android:textStyle =”bold” 设置字形[bold(粗体) 0, italic(斜体) 1, bolditalic(又粗又斜) 2] 可以设置一个或多个,用“|”隔开
android:typeface = “normal ” 设置文本字体,必须是以下常量值之一:normal 0, sans 1, serif 2, monospace(等宽字体) 3]
android:lineSpacingExtra = “10sp”设置行间距。
android:textScaleX = “1.2”设置文字X轴的比例。
EditText
android:hint=”请输入数字!”//设置显示在空间上的提示信息
android:textColorHint=”#ffff00”//设置提示信息文字的颜色,默认为灰色
android:singleLine=”true”//设置单行输入,一旦设置为true,则文字不会自动换行。
android:password=”true”//设置只能输入密码
android:background=”@null”//背景,可以是图片,也可以是纯色,这里没有,指透明
android:cursorVisible=“true”设定光标为显示/隐藏,默认显示
android:gravity=”center”设置文本位置,如设置成“center”,文本将居中显示。
ImageView
ImageView控键的使用
android:src=”@drawable/ic_launcher22”
(1)drawable-hdpi对应 (480x800)(480x854)
(2)drawable-mdpi对应 (320x480)
(3)drawable-ldpi对应 (240x320)
(4)drawable-xdpi对应 (720x1280)
(5)drawable-xxdpi对应(1080x1800)
CheckBox
如题复选框,即可以同时选中多个选项,至于获得选中的值,同样有两种方式:
1.为每个CheckBox添加事件:setOnCheckedChangeListener
2.弄一个按钮,在点击后,对每个checkbox进行判断:isChecked();
1,android:checked=”true”
2,isChecked
RadioButton
此处转载引用于:http://hualang.iteye.com/blog/964507
网址中有详细的例子介绍
RadioButton和RadioGroup配合使用
RadioButton的单选按钮;
RadioGroup是单选组合框,用于将RadioButton框起来;
在没有RadioGroup的情况下,RadioButton可以全部都选中;
当多个RadioButton被RadioGroup包含的情况下,RadioButton只可以选择一个;
注意:单选按钮的事件监听用setOnCheckedChangeListener来对单选按钮进行监听
相关文章推荐
- 【朝花夕拾】Android编码风格篇
- android 游戏 实战打飞机游戏 菜单页面(1)
- Android中的显式 Intent和隐式 Intent
- Android系统 小米/三星/索尼 应用启动图标未读消息数(BadgeNumber)动态提醒
- overridePendingTransition
- Matrix pre post set操作的含义
- Android中的View简介
- Android 开源框架Universal-Image-Loader完全解析(一)--- 基本介绍及使用
- android 4.4打印功能
- 标准对话框 AlertDialog 使用
- Android直接使用JDBC+SSH连接外网MySQL数据库
- android实现图片旋转
- Android Studio Gradle打包实践之多渠道+版本号管理
- Android开发学习之路-Android6.0运行时权限
- android_事件分发相关,看这两篇文章,就足够
- RecyclerView简单使用
- AndroidSlidingUpPanel简析
- 为什么在Android Studio中找不到Subversion
- Android图片剪裁-调用系统实现,完美适配魅族等机型
- 【转】开发者教程:如何将Android应用发布到Google Play(Android Market)官方市场