您的位置:首页 > 移动开发 > Android开发

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来对单选按钮进行监听
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: