TextView之二:常用属性
参考自《疯狂android讲义》2.3节
实例一:TextView的常用属性
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<!-- 设置字体为20pt,文本框结尾处绘制图片 -->
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="我爱Java"
android:textSize="20pt"
android:drawableEnd="@drawable/ic_launcher"
/>
<!-- 设置中间省略, 所有字母大写 -->
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="我爱Java我爱Java我爱Java我爱Java我爱Java我aaaJava"
android:ellipsize="middle"
android:textAllCaps="true"
/>
<!-- 对邮件、电话增加链接 -->
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="邮件是kongyeeku@163.com,电话是02088888888"
android:autoLink="email|phone"
/>
<!-- 设置文字颜色 、大小,并使用阴影 -->
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="测试文字"
android:shadowColor="#0000ff"
android:shadowDx="10.0"
android:shadowDy="8.0"
android:shadowRadius="3.0"
android:textColor="#f00"
android:textSize="18pt"
/>
<!-- 测试密码框 -->
<TextView android:id="@+id/passwd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:password="true"
/>
<!-- 测试CheckedTextView
通过checkMark设置该文本框的勾选图标
-->
<CheckedTextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="可勾选的文本"
android:checkMark="@drawable/ok"
/>
</LinearLayout>
效果图如下:
实例二:使用xml文件指定drawable资源,并用之于TextView的背景
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
><!-- 通过android:background指定背景 --><TextViewandroid:layout_width="match_parent" android:layout_height="wrap_content"android:text="带边框的文本"android:textSize="24pt"android:background="@drawable/bg_border"/><!-- 通过android:drawableLeft绘制一张图片 --><TextView android:layout_width="match_parent"android:layout_height="wrap_content"android:text="圆角边框、渐变背景的文本"android:textSize="24pt"android:background="@drawable/bg_border2"/></LinearLayout>
bg_border.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 设置背景色为透明色 -->
<solid android:color="#0000"/>
<!-- 设置红色边框 -->
<stroke android:width="4px" android:color="#f00" />
</shape>bg_border2.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 指定圆角矩形的4个圆角的半径 -->
<corners android:topLeftRadius="20px"
android:topRightRadius="5px"
android:bottomRightRadius="20px"
android:bottomLeftRadius="5px"/>
<!-- 指定边框线条的宽度和颜色 -->
<stroke android:width="4px" android:color="#f0f" />
<!-- 指定使用渐变背景色,使用sweep类型的渐变
颜色从红色→绿色→蓝色 -->
<gradient android:startColor="#f00"
android:centerColor="#0f0"
android:endColor="#00f"
android:type="sweep"/>
</shape>
TextView之二:常用属性的更多相关文章
- Android中TextView和EditView常用属性设置
Android中TextView和EditView常用属性设置 点击跳转
- android软件开发之TextView控件常用属性
TextView控件 text属性,设置显示的文本 textColor:设置文本颜色 textSize:设置文本字体大小 autoLink:设置文本为电话,URL连接等的时候是否显示为可点击的链接 c ...
- TextView控件常用属性
常用属性 android:id——控件ID android:layout_width——控件宽度 android:layout_height——控件高度 android:text——文本内容 andr ...
- TextView子类的常用属性
TextView常见的子类包括EditText,Button,CheckBox, RadioButton等. 1.EditText EditText继承自TextView,因此TextView所有属性 ...
- TextView之二:常用属性 分类: H1_ANDROID 2013-10-30 12:43 3203人阅读 评论(0) 收藏
参考自<疯狂android讲义>2.3节 //TextView所呈现的文字 android:text="我爱Java" //文字颜色 android:textColor ...
- Android EditText常用属性
一.EditText介绍 ①EditText是一个输入框,在Android开发中是常用的控件.也是获取用户数据的一种方式. ②EditText是TextView的子类,它继承了TextView的所有属 ...
- iOS导航控制器常用函数与navigationBar常用属性
导航控制器常用函数触发时机 当视图控制器的View将要出现时触发 - (void)viewWillAppear:(BOOL)animated 当视图控制器的View已经出现时触发 - (void)vi ...
- 12-27 UITableView常用属性及方法
UITableView也有自己的代理协议,它本身继承自UIScrollView 一:代理要遵守代理协议<UITableViewDelegate>,代理协议中的代理方法: 1.改变某一行的行 ...
- Swift2.0 中的String(一):常用属性
字符串算是平常用的比较多.花样也比较多的一个类型,昨天有空把相关的一些常用操作都写了一遍,总结出来.其实iOS里面的字符串更复杂,还有NSString系列等等,那些API太多将来需要用的时候再慢慢学. ...
随机推荐
- #能力开放平台系列-Fiddler访问Rest服务
问题 最近开发能力开放平台,需要将Dubbo服务转换成Rest服务,虽然转换很成功(后续文档会写出如何将Dubbo服务转换成Rest接口),但是调试起来特别的麻烦. 解决方案: Fiddler解决方案 ...
- ubuntu14.04中解压缩window中的zip文件,文件名乱码的解决方法
在windows上压缩的文件,是以系统默认编码中文来压缩文件.由于zip文件中没有声明其编码,所以linux上的unzip一般以默认编码解压,中文文件名会出现乱码. 通过unzip行命令解压,指定字符 ...
- show,hide与fadeIn、fadeOu的区别
show,hide——>是通过改变height,width,opacity来实现动画的显示与隐藏的 fadeIn.fadeOut——>只通过opacity来实现动画的显示与隐藏的 它们两个 ...
- C语言之利用递归将十进制转换为二进制
#include<stdio.h>#include<stdlib.h>void change2(int num){ if (num != 0) { change2(n ...
- table行转列
table行转列 摘要 在使用ews调用exhange的收件箱的并在h5页面显示邮件详情的时候,因为返回的每封邮件的内容都是htmlbody,没有textbody.每封邮件又没什么规律,用正则表达式来 ...
- 双人贪吃蛇小游戏C++原创
大家好,我是小鸭酱,博客地址为:http://www.cnblogs.com/xiaoyajiang /*贪吃蛇*/ #include<stdio.h> #include<time. ...
- 【转】Android(4.2) Sensors 学习——G-sensor,Gyroscope驱动移植
原文网址:http://blog.csdn.net/nxh_love/article/details/11804841 本人对驱动可谓是一点不懂,鉴于公司目前高驱动的人手不够,所以我也只能两眼一抹黑硬 ...
- zedboard--Opencv移植和zedboard测试(十一)
继上次生成了ARM架构的链接库之后,我们要把他们拷贝到装载有文件系统的SD卡中即可,在拷贝时,最好是/usr/lib下 实践一:将那些lib拷贝到U盘里面,因为之前跑过demo,里面就是一个简易的li ...
- VBA清除Excelpassword保护,2003/2007/2010均适用
Sub Macro1() ' ' Breaks worksheet and workbook structure passwords. Jason S ' probably originator of ...
- UIView属性clipsTobounds的应用
view添加view,并剪边(UIView属性clipsTobounds的应用) 如题,有两个view: view1,view2 view1添加view2到其中,如果view2大于view1,或者vi ...