现在的位置: 首页 > 综合 > 正文

android学习笔记17:文字设置

2013年08月05日 ⁄ 综合 ⁄ 共 1261字 ⁄ 字号 评论关闭

在Android文字可以设置的属性包括大小,颜色,是否是密码,是否显示阴影,超链接,文字无法显示的时候的省略规则等。

<?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="我爱yanzi"
	android:textSize="20pt"
	/>
	<!-- 设置中间省略 -->
	<TextView
	android:layout_width="fill_parent" 
	android:layout_height="wrap_content"
	android:singleLine="true" 
	android:text="我爱yanzi我爱yanzi我爱yanzi我爱yanzi我爱yanzi我aaayanzi"
	android:ellipsize="middle"
	/>
	<!-- 对网址增加链接 -->
	<TextView
	android:layout_width="fill_parent" 
	android:layout_height="wrap_content"
	android:singleLine="true" 
	android:text="测试http://blog.csdn.net/hn307165411内容"
	android:autoLink="all"
	/>
	<!-- 设置文字颜色 、大小,并使用阴影 -->
	<TextView
	android:layout_width="fill_parent" 
	android:layout_height="wrap_content" 
	android:text="测试文字"
	android:shadowColor="#0000ff"
	android:shadowDx="15.0"
	android:shadowDy="20.0"
	android:shadowRadius="45.0"
	android:textColor="#ff0000"
	android:textSize="25pt"
	/>
	<!-- 测试密码框 -->
	<TextView android:id="@+id/passwd"
	android:layout_width="fill_parent" 
	android:layout_height="wrap_content" 
	android:text="@string/hello"
	android:password="true"
	/>
</LinearLayout>

抱歉!评论已关闭.