03安卓TextView
一 TextView 父类 : View
>概念:文本控件 :文本内容的显示 默认配置不可编辑 子类EditText可以编辑
*********************************
注意:安卓中如果在TextView中英文混用将有空可能自动折断到下行 ,如果是中文符号和英文混用将中文符号转换为半角。在安卓5.0后解决了这个BUG 或者删除 详情解决办法:http://niufc.iteye.com/blog/1729792
*********************************
>属性:
android:text="你好,世界!" 文本内容
android:textSize="20sp" 文本字体的大小
android:textColor="#f00" 文本颜色
android:textStyle="bold|italic" 文本字体样式
bold:加粗
italic:斜体
android:maxLength="1" 最大显示字符数
android:maxLines="2":文本最多展示的行数
android:singleLine="true" 文本过多单行展示文本内容
android:ellipsize="none" 省略号的位置
none: 没有
start:开始位置
middle:中间位置
end:结尾位置
marquee:跑马灯
跑马灯必要条件:
android:singleLine="true" 单行展示
android:ellipsize="marquee" 设置成跑马灯样式
android:focusableInTouchMode="true" 设置获取焦点模式
android:focusable="true" 设置获取焦点
android:marqueeRepeatLimit="marquee_forever" 跑马灯无限循环
android:autoLink="phone"自动链接 (根据内容不同 打开相应的程序)
phone 电话
web 网址
map 地图
email 邮箱
all 以上所有
设置阴影效果
android:shadowColor="#0f0" 阴影的颜色
android:shadowDx="10.0" 阴影水平偏移量
android:shadowDy="8.0" 阴影垂直偏移量
android:shadowRadius="2" 阴影模糊程度 (值越大 越模糊)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.fmy.img.MainActivity" > <!--
android:maxLength="1"设置最大字符数
android:textColor="#ff0000"设置颜色 -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLength="1"
android:text="Hello wrold"
android:textColor="#ff0000" />
<!--
android:textColor="#ff0000"设置颜色
android:textStyle="italic|bold"设置斜体和加粗
-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello wrold"
android:textColor="#ff0000"
android:textStyle="italic|bold" />
<!--
android:singleLine="true"设置单行
-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="Hello wrold Hello wrold Hello wrold Hello wrold Hello wrold Hello wrold Hello wrold" />
<!--
android:maxLines="2"设置最大行数
android:ellipsize="middle"设置省略中间文字
android:ellipsize="start"设置省略开始文字
android:ellipsize="end"设置省略文字后端
-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="start"
android:maxLines="2"
android:text="Hello wrold Hello wrold Hello wrold Hello wrold Hello wrold Hello wrold Hello 我是最后" />
<!--
ellipsize="marquee"设置跑马灯
设置跑马灯的前提:
focusableInTouchMode 设置焦点模式
marqueeRepeatLimit 设置跑马灯循环次数
singleLine="true"设置单行
focusable 获得焦点
-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:text="Hello wrold Hello wrold Hello wrold Hello wrold Hello wrold Hello wrold Hello 我是最后" />
<!--
android:autoLink="map"打开地图
android:autoLink="phone"打开text的电话
android:autoLink="web"打开text的网页
android:autoLink="email"设置text的邮箱链接到邮箱
android:text="635555698@qq.com"
-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="map"
android:text="635555698@qq.com" />
<!--
android:shadowDx="10" 设置阴影x离左上角的位置
android:shadowDy="10" 设置阴影y离左上角的位置
android:shadowRadius="2" 設置影印模糊度
-->
<TextView
android:shadowDx="10"
android:shadowDy="10"
android:shadowRadius="2"
android:shadowColor="#f00"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="影音效果" /> </LinearLayout>
03安卓TextView的更多相关文章
- 解决安卓TextView异常换行,参差不齐等问题
参考:http://blog.csdn.net/u012286242/article/details/28429267?utm_source=tuicool&utm_medium=referr ...
- 解决安卓TextView高度和textSize大小不一致问题
在设计安卓界面的时候我发现一个TextView在布局上占用的高度和属性textSize的大小不一样,要比textSize要来的大(比如textSize="12dp",实际的高度大概 ...
- 安卓TextView限定行数最大值,点击按钮显示所有内容
问题展示 如上图所示,在普通的TextView中,要求: 最多显示3行 超过三行显示展开按钮 且点击展开按钮显示完整内容 这个需求看似简单,但解决起来会遇到两个较为棘手的问题:1,如何判断是否填满了前 ...
- 安卓TextView完美展示html格式代码
对于TextView展示html格式代码,最简单的办法就是使用textview.setText(Html.fromHtml(html));,即便其中有img标签,我们依然可以使用ImageGetter ...
- 安卓Textview的getLineCount返回0
ViewTreeObserver observer = tv.getViewTreeObserver(); // textAbstract为TextView控件 observer.addOnGloba ...
- 安卓 textview 换行 不满就换了
public static String ToDBC(String input) { char[] c = input.toCharArray(); for (int i = 0; i < c. ...
- TextView之富文本
项目中使用富文本比较常见了,一行显示多种样式颜色的文本,使用 ClickableSpan 富文本实现在同一个 TextView 中的文本的颜色.大小.背景色等属性的多样化和个性化. 我们也可以使用Ht ...
- Json学习篇
JSON的定义: 一种轻量级的数据交换格式,具有良好的可读和便于快速编写的特性.业内主流技术为其提供了完整的解决方案(有点类似于正则表达式 ,获得了当今大部分语言的支持),从而可以在不同平台间进行 ...
- 22个值得收藏的Android开源代码-UI篇
本文介绍了android开发者中比较热门的开源代码,这些代码绝大多数可以直接应用到项目中. FileBrowserView 一个强大的文件选择控件.界面比较漂亮,使用也很简单.特点:可以自定义UI:支 ...
随机推荐
- Union和Union All 的区别
Union和Union All 的区别: Union 是对结果集进行并集操作,不包括重复行,同时进行默认规则的排序: Union All,对两个结果集进行并集操作,包括重复行,不进行排序: Inter ...
- (转)SQL中的循环、for循环、游标
我们使用SQL语句处理数据时,可能会碰到一些需要循环遍历某个表并对其进行相应的操作(添加.修改.删除),这时我们就需要用到咱们在编程中常常用的for或foreach,但是在SQL中写循环往往显得那么吃 ...
- Linux 查看系统硬件信息汇总 (部份实例详解Centoso为例)
1.cpu #lscpu命令,查看的是cpu的统计信息.(部分旧版本不支持) Disk /dev/sda: bytes heads, sectors/track, cylinders Units = ...
- 使用mybatis注解@Options实现添加记录时返回主键值
官网:http://www.mybatis.org/mybatis-3/index.html 在使用mybatis作为ORM框架时,我通常更喜欢使用注解而非xml配置文件的方式.业务场景:添加记录之后 ...
- java客户端Jedis操作Redis Sentinel 连接池
pom配置: <dependency> <groupId>org.springframework.data</groupId> <artifactId> ...
- 基于PHP的地址智能解析案例-快宝开放平台
快宝地址智能解析,批量录入收件人.发件人最好的解决方案,广泛应用于快递行业,电商行业,ERP应用等. 一.对接前准备 注册快宝开放平台,获得开发者账号,查看如何注册. 二.对接联调 快宝开放平台支持多 ...
- Win10 下Cmake编译配置 Opencv3.1 + Cuda7.5 + VS2013
折腾了三天终于配置成功了,在此写下编译配置的全部步骤和遇到的很多坑. 整体介绍: OpenCV 中 CUDA 实现的函数还不是太多,使用前要在OpenCV的官网上确认以下你想要的功能是否已经实现,否则 ...
- 什么是 Docker
Docker 是一个开源项目,诞生于 2013 年初,最初是 dotCloud 公司内部的一个业余项目.它基于 Google 公司推出的 Go 语言实现. 项目后来加入了 Linux 基金会,遵从了 ...
- EntityFramework Core 自动绑定模型映射
笔者最近在和同事共同开发项目时,需要从他们提供的包含数据库实体类型的类库中读取实体信息绑定到自己的项目中(但是都在同一个解决方案里),所以很直接的一种方式就是把项目中所有的实体都以 public Db ...
- Redis之(七)主从同步与集群管理
8.1 主从同步原理 像MySQL一样,Redis是支持主从同步的,而且也支持一主多从以及多级从结构. 主从结构,一是为了纯粹的冗余备份,二是为了提升读性能,比如很消耗性能的SORT就可以由从服务器来 ...