Android常用控件一之文本控件
2017-06-04 01:32
155 查看
1、显示文本的控件(TextView)
android:text 设置文本框内文本内容
android:autoLink 是否将符合格式的文本转化为可单击的超链接形式
取值范围:none (无)| web(网址)| phone(电话)| map(地址)| all(都可以,系统判断)
android:minLines 最少占几行
android:textColor 字体颜色
android:textSize 字体大小
android:background 设置背景 可以是颜色或图片
android:typeface
1、字体
2、android系统默认支持三种字体
3、要使用其他字体,需要把字体文件(.tff)放在assets/fonts目录下,然后使用代码设置
4、代码:
4.1、Typeface typeFace=Typeface.createFromAsset(getAssets(),"fonts/FZSTK.TTF");
4.2、textView.setTypeface(typeFace);
android:ellipsize 文本超过TextView的长度是如何处理
取值范围:none | start | middle | end | marquee
如果取值为marquee 需要加上三个属性
1、android:focusable="true"
2、android:focusableInTouchMode="true"
3、android:clickable="true"
marquee默认无限循环,可以通过android:marqueeRepeatLimt="1"设置循环次数
android:drawableXX 设置文本的icon,XX是任意的方向,在字体的哪个方向添加
android:text 设置文本框内文本内容
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="我是文本控件的内容" />
android:autoLink 是否将符合格式的文本转化为可单击的超链接形式
取值范围:none (无)| web(网址)| phone(电话)| map(地址)| all(都可以,系统判断)
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="https://www.baidu.com/" android:autoLink="web" />android:lines 默认占几行
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="1234567890234234234234234234242342423423423423423409" android:lines="1" />
android:minLines 最少占几行
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="12345678902342342342342342342423424234234234234234098765432434234234234" android:minLines="2" />
android:textColor 字体颜色
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="我是字体颜色控件" android:textColor="@color/colorPrimary" />
android:textSize 字体大小
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="我是字体大小控件" android:textSize="15dp" />android:textStyle 字体风格 如粗体 斜体等
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="我是字体样式控件" android:textStyle="bold" />
android:background 设置背景 可以是颜色或图片
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="我是字体背景控件" android:background="@color/colorPrimaryDark" />
android:typeface
1、字体
2、android系统默认支持三种字体
3、要使用其他字体,需要把字体文件(.tff)放在assets/fonts目录下,然后使用代码设置
4、代码:
4.1、Typeface typeFace=Typeface.createFromAsset(getAssets(),"fonts/FZSTK.TTF");
4.2、textView.setTypeface(typeFace);
android:ellipsize 文本超过TextView的长度是如何处理
取值范围:none | start | middle | end | marquee
如果取值为marquee 需要加上三个属性
1、android:focusable="true"
2、android:focusableInTouchMode="true"
3、android:clickable="true"
marquee默认无限循环,可以通过android:marqueeRepeatLimt="1"设置循环次数
android:drawableXX 设置文本的icon,XX是任意的方向,在字体的哪个方向添加
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="我是字体icon控件" android:drawableLeft="@drawable/icon_user" />
相关文章推荐
- 【Android常用控件】EditText常用属性【二】:为文本输入框指定软键盘类型和软键盘回车键图标设置
- Android—常用控件(一)文本控件
- 【Android常用控件】EditText常用属性【二】:为文本输入框指定软键盘类型和软键盘回车键图标设置
- Android常用控件二之编辑文本的控件
- Android学习笔记--Android开发时常用控件(三)
- Android基础(四) 常用控件
- android中常用的一些控件
- androidUI第六部分---其他常用控件举例
- CRichEditCtrl 超文本编辑(MSN/QQ常用控件)(转)
- 横秋扫盲系列(4): CRichEditCtrl 超文本编辑(MSN/QQ常用控件) -- 2005-08-28 21:13:15
- Android开发笔记--Android开发时常用控件(二)
- vs2005简单的使用控件,实现网站常用的任意文本超链接
- Android常用控件-DatePicker以及对话框的两种使用方法
- Android常用控件-TextView、EditView、Button、Menu
- Android 中的几个常用控件
- Android基础(四) 常用控件的事件处理
- Android常用控件的信息!
- 下表列出了文本控件的常用通知消息:
- Android学习第二天:Intent传输数据、常用控件和Activity生命周期
- android:cha1.3 常用控件的设置