不同颜色,不同字体,带链接的TextView和CheckedTextView
<?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"> <!-- 设置字号为20sp,文本框结尾处绘制图片 --> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="我爱java" android:textSize="20sp" android:drawableEnd="@drawable/ic_launcher" /> <!-- 设置中间省略,所有字母大写 --> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" android:text="java" android:ellipsize="middle" android:textAllCaps="true" ></TextView> <!-- 对邮件、电话增加链接 --> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" android:text="邮件是sadas@qq.com,电话是13025421421" android:autoLink="email|phone" ></TextView> <!-- 设置文字颜色、大小、并使用阴影 --> <TextView android:layout_width="fill_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="18sp" ></TextView> <!-- 测试密码框 --> <TextView android:id="@+id/password" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello_world" android:password="true" ></TextView> <CheckedTextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="可勾选的文本" android:checkMark="@drawable/ic_launcher" ></CheckedTextView> </LinearLayout>