Android常用控件一之文本控件
来源:互联网 发布:5g网络产业链 编辑:程序博客网 时间:2024/05/19 16:49
1、显示文本的控件(TextView)
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" />
阅读全文
0 0
- Android常用控件一之文本控件
- Android—常用控件(一)文本控件
- Android常用控件二之编辑文本的控件
- Android常用控件之ListView(一)
- Android常用控件(一)
- Android常用控件(一)
- Android 常用控件一
- Android常用控件 一(文本控件,android资源,selector选择器)
- android常用控件总结(一)
- Android 常用控件(一)
- android 常用控件(一)
- Android常用控件四之日期控件
- Android常用控件五之时间控件
- 常用文本控件
- 常用文本控件
- 文本控件验证 (一)
- Android常用控件之ViewPager
- Android常用控件之SoundPool
- 虚伪的自己
- c++ 串
- #Paper Reading# A Neural Attention Model for Abstractive Sentence Summarization
- 第二章 第二个spring-boot程序
- 二维数组通过指针旋转90度
- Android常用控件一之文本控件
- KBEngine 房间示例创建脚本调用解读
- mysql之sql语句练级攻略
- 深度神经网络(DNN)模型与前向传播算法
- Android 开机动画bootanimation
- 关于Java在控制台对齐打印
- 关于Java在控制台对齐打印
- C++与c的写法不同在哪里?
- *N皇后问题