现在的位置: 首页 > 综合 > 正文

Android 控件xml属性详解

2013年07月09日 ⁄ 综合 ⁄ 共 1681字 ⁄ 字号 评论关闭

属性

说明

android:orientation

horizontal/vertical

设置布局水平还是垂直,默认是垂直

android:checked

true/false

标记默认选中,如果是单选则选中最后一个

android:layout_gravity

center/right/left/bottom/top

位置

android:gravity

center/right/left/bottom/top

位置(android:gravity属性是对该view内容的限定.比如一个button上面的text.你可以设置该text在view的靠左,靠右等位置.该属性就干了这个.android:layout_gravity是用来设置该view相对与起父view的位置.比如一个button在linearlayout里,你想把该button放在靠左靠右等位置就可以通过该属性设置.)

android:hint

@string

提示信息,当文本框为空的时候显示

android:numeric

integer/decimal

只能输入整数/小数

android:singleLine

true/false

设置单行输入,一旦设置为true,则文字不会自动换行

android:password

true/false

设置密码框

android:textColor

#ffffff

字体颜色

android:textStyle

bold/italic/bolditalic

设置字形[bold(粗体) 0, italic(斜体) 1, bolditalic(又粗又斜) 2] 可以设置一个或多个,用“|”隔开

android:textSize

20dip

字体大小

android:capitalize

characters

设置英文字母大写类型。此处无效果,需要弹出输入法才能看得到

android:textAlign

center/right/left

设置文字显示位置,EditText没有这个属性,但TextView有

android:autoText

true/false

如果设置,将自动执行输入值的拼写纠正。此处无效果,在显示输入法并输入的时候起作用。

android:editable

true/false

是否可编辑

android:textColorHighlight

#ffffff

被选中文字的底色

android:textColorHint

#ffffff

设置提示信息文字的颜色,默认为灰色

android:textScaleX

1.5

控制字与字之间的间距

android:typeface

normal/sans/serif/monospace

 

android:background

@null

空间背景,这里没有,指透明,将EditText自定义的背景去掉

android:layout_weight

1

权重,控制控件之间的地位,在控制控件显示的大小时蛮有用的。

android:textAppearance

textAppearanceButton、textAppearanceInverse、textAppearanceLarge、textAppearanceLargeInverse、textAppearanceMedium、textAppearanceMediumInverse、textAppearanceSmall、textAppearanceSmallInverse

设置文字外观。如“?android:attr/textAppearanceLargeInverse”这里引用的是系统自带的一个外观,?表示系统是否有这种外观,否则使用默认的外观。

android:autoLink

none、web、email、phone、map、all

设置是否当文本为URL链接/email/电话号码/map时,文本显示为可点击的链接。

android:cursorVisible

true/false

设定光标为显示/隐藏,默认显示。

android:digits

1234567890.+-*/%\n()

设置允许输入哪些字符。

android:drawableBottom

抱歉!评论已关闭.