android中控件的大部分属性解释.docx

上传人:b****6 文档编号:5994312 上传时间:2023-01-02 格式:DOCX 页数:7 大小:17.92KB
下载 相关 举报
android中控件的大部分属性解释.docx_第1页
第1页 / 共7页
android中控件的大部分属性解释.docx_第2页
第2页 / 共7页
android中控件的大部分属性解释.docx_第3页
第3页 / 共7页
android中控件的大部分属性解释.docx_第4页
第4页 / 共7页
android中控件的大部分属性解释.docx_第5页
第5页 / 共7页
点击查看更多>>
下载资源
资源描述

android中控件的大部分属性解释.docx

《android中控件的大部分属性解释.docx》由会员分享,可在线阅读,更多相关《android中控件的大部分属性解释.docx(7页珍藏版)》请在冰豆网上搜索。

android中控件的大部分属性解释.docx

android中控件的大部分属性解释

android中控件的大部分属性解释

属性 值说明

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

在text的下方输出一个drawable,如图片。

如果指定一个颜色的话会把text的背景设为该颜色,并且同时和background使用时覆盖后者。

 

android:

drawableLeft

在text的左边输出一个drawable,如图片。

 

android:

drawableRight

在text的右边输出一个drawable,如图片。

 

android:

drawableTop

在text的正上方输出一个drawable,如图片。

 

android:

drawablePadding

设置text与drawable(图片)的间隔,与drawableLeft、drawableRight、drawableTop、drawableBottom一起使用,可设置为负数,单独使用没有效果。

 

android:

editorExtras

指定特定输入法的扩展,如“com.mydomain.im.SOME_FIELD”。

源码跟踪至EditorInfo.extras,暂无相关实现代码。

 

android:

ellipsize

start、end、middle、marquee

设置当文字过长时,该控件该如何显示。

有如下值设置:

”start”省略号显示在开头;”end”省略号显示在结尾;”middle”省略号显示在中间;”marquee”以跑马灯的方式显示(动画横向移动)

android:

freezesText

true/false

设置保存文本的内容以及光标的位置,再到相应的Activity中加上如下两个方法,实现方法网站找一下,这里不详细说明。

android:

imeOptions

normal,actionUnspecified,actionNone,actionGo,actionSearch,actionSend,actionNext,actionDone,flagNoExtractUi,flagNoAccessoryAction,flagNoEnterAction

设置软键盘的Enter键。

可用’|’设置多个。

android:

imeActionId

设置IME动作ID,在onEditorAction中捕获判断进行逻辑操作。

 

android:

imeActionLabel

设置IME动作标签。

但是不能保证一定会使用,猜想在输入法扩展的时候应该有用。

 

android:

includeFontPadding

true/false

设置文本是否包含顶部和底部额外空白,默认为true。

android:

inputMethod

为文本指定输入法,需要完全限定名(完整的包名) 

android:

inputType

设置文本的类型,用于帮助输入法显示合适的键盘类型。

有如下值设置:

none、text、textCapCharacters字母大小、textCapWords单词首字母大小、textCapSentences仅第一个字母大小、textAutoCorrect、textAutoComplete自动完成、textMultiLine多行输入、textImeMultiLine输入法多行(如果支持)、textNoSuggestions不提示、textEmailAddress电子邮件地址、textEmailSubject邮件主题、textShortMessage短信息(会多一个表情按钮出来)、textLongMessage长讯息?

、textPersonName人名、textPostalAddress地址、textPassword密码、textVisiblePassword可见密码、textWebEditText作为网页表单的文本、textFilte文本筛选过滤、textPhonetic拼音输入、numberSigned有符号数字格式、numberDecimal可带小数点的浮点格式、phone电话号码、datetime时间日期、date日期、time时间。

 

android:

linksClickable

设置链接是否点击连接,即使设置了autoLink 

android:

maxLines

设置文本的最大显示行数,与width或者layout_width结合使用,超出部分自动换行,超出行数将不显示 

android:

minLines

设置文本的最小行数 

android:

lineSpacingExtra

设置行间距。

 

android:

phoneNumber

true/false

设置为电话号码的输入方式。

android:

privateImeOptions

提供额外的输入法选项(字符串格式)。

 

android:

scrollHorizontally

true/false

设置文本超出TextView的宽度的情况下,是否出现横拉条。

android:

selectAllOnFocus

如果文本是可选择的,让他获取焦点而不是将光标移动为文本的开始位置或者末尾位置。

 

android:

shadowColor

指定文本阴影的颜色,需要与shadowRadius一起使用。

 

android:

shadowRadius

设置阴影的半径。

设置为0.1就变成字体的颜色了,一般设置为3.0的效果比较好。

 

android:

shadowDx

设置阴影横向坐标开始位置。

 

android:

shadowDy

设置阴影纵向坐标开始位置。

 

android:

textColorLink

#ffffff

文字链接的颜色.

android:

maxHeight

设置文本区域的最大高度 

android:

minHeight

设置文本区域的最小高度 

android:

maxWidth

设置文本区域的最大宽度 

android:

minWidth

设置文本区域的最小宽度 

android:

clickable

true/false

view是否能对click事件作出反应

android:

onClick

当view被click之后,view的context的哪个方法被呼叫。

通常这个context是指view所在的Activity。

例如:

android:

onClick='sayHello',则相应的Activity里面有一个方法public void sayHello(View view)方法,当这个view被click之后,sayHello方法就会被调用。

 

android:

longClickable

true/false

view是否可以对长时间的click事件作出反应。

android:

focusable

view是否能响应焦点事件 

android:

cacheColorHint

#00000000

滚动时,列表里面的view重绘时,用的依旧是系统默认的透明色,颜色值为#FF191919,要改变这种情况,只需要调用 listView的setCacheColorHint(0),颜色值设置为0或者xml文件中listView的属性 Android:

cacheColorHint="#00000000"即可,滚动时,重绘View的时候就不会有背景颜色。

android:

fadingEdgeLength

设置边框渐变的长度。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 人文社科 > 哲学历史

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1