控件 TextView、EditText

来源:互联网 发布:只有我知 杭州见面会 编辑:程序博客网 时间:2024/06/05 08:32

常用控件

一、文本控件:

TextView(显示文本的控件)

1、Android:text  设置文本框文本内容

2、Android:autoLink

是否将符合指定格式的文本转换可单击的超链接形式,取值范围:none|web|email|phone|map|all

3、android:singleLine  true文本框不会换行

4、Android:lines 默认占几行

5、Android:minLines 最少占几行

6、Android:textColor 字体颜色

7、Android:textSize  字体大小

8、Android:textStyle  字体风格如粗体、斜体等

9、Android:background 设置背景;可以是图片也可以是颜色

10、Android:typeface

(1) 字体

(2)android系统默认支持三种字体

(3)要使用其他字体,需要把字体文件(.ttf)放在assets/fonts目录下,然后使用代码设置

(4)代码:Typeface t=Typeface.createFromAsset(getAssets(),”fonts/FZSTK.TTF”);

textView.setTypeface(typeFace);

11、Android:ellipsize

(1)文本超过TextView的长度是如何处理

(2)取值范围:none|start|middle|end|marquee(循环)

(3)如果取值为marquee需要加上三个属性:

Android:focusable=”true”

Android:focusableInTouchMode=”true”

Android:clickable=”true”

(4)marquee默认为无限循环,可以通过android:marqueeRepeatLimit=”1” 设置循环次数

12、android:drawablexx 设置文本的icon


二、EditText(编辑文本的控件)

EditViewTextView的子类

1.Android:password  字密码框

2.Android:phoneNumber 电话密码框

3.Android:inputType=”” 以上两种为过去时写法,推荐使用这种

4.android:textColorHightlight 文字被选中时的背景颜色

5.android:hint 提示字符信息

原创粉丝点击