TextView中的常用属性

TextView 属性效果展示:

150944_4HS6_109481.jpg

效果描述: 

第一个文本框后面加了一个图片,第二个中间省略,字母全大写

第三个有超链接,第四个有阴影,第五个字母变点,第六个有勾选图片

对应的属性介绍:

TextView中的XML属性介绍:
//第一行:
 android:drawableEnd="@drawable/ic_launcher” 在文本框的结尾处绘制图片。
//第二行:
android:textAllCaps=“true" 该文本框的所有字母大写。
android:ellipsize=“middle" 当文本多于文本框的长度时,从中间省略文本。
//第三行:
android:autoLink="email|phone”  该文本框会自动为改文本框内的电话和Email添加超链接。
//第四行:
android:shadowColor="#00f"
android:shadowDx="10.0"
android:shadowDy="8.0"
android:shadowRadius=“3.0"
android:shadowXXXX  为该文本框的内容添加了阴影
//第五行
android:password=“true"  该文本框会用点来代替所有文字
//第六行  (CheckedTextView)
android:checkMark="@drawable/ok”该可勾选文本框的勾选图标。

相应的代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
           android:orientation="vertical"
           android:layout_width="match_parent"
           android:layout_height="match_parent">
   <!-- 设置字号为20pt,文本框结尾处绘制图片  -->
   <TextView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="我爱Java"
      android:textSize="20pt"
      android:drawableEnd="@drawable/ic_launcher"/>
   <!-- 设置中间省略,所有字母大写 -->
   <TextView
      android:layout_width="match_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="match_parent"
      android:layout_height="wrap_content"
      android:singleLine="true"
      android:text="邮件是kongyeeku@163.com,电话是02088888888"
      android:autoLink="email|phone"/>
   <!-- 设置文字颜色、大小,并使用阴影 -->
   <TextView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="测试文字"
      android:shadowColor="#00f"
      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="match_parent"
           android:layout_height="wrap_content"
           android:text="@string/hello_world"
           android:password="true"/>
   <CheckedTextView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="可勾选的文本"
      android:checkMark="@drawable/ok" />
</LinearLayout>


参考:疯狂Android讲义

转载于:https://my.oschina.net/cuitongliang/blog/486135

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值