TextView主要用来显示丰富的文本信息,也可以用来显示图文并茂的混排页面。
android:text 设置文本内容 @string/xx
android:textColor 设置文本字体颜色 RGB的形式
android:textStyle 设置文本字体样式 bold表示加粗 italic表示斜体 设置多个用 | 隔开
android:textSize 设置文本字体大小 单位使用sp(缩放像素)
android:singleLine 设置文本是否单行展示
android:autoLink 给指定的文本增加可点击的超链接
-none
-map
-all
-phone
-web
-email 设置多个用 | 隔开
android:drawableTop 表示设置TextView控件上方显示的图片 @drawable/xx
android:drawableBottom
android:drawableLeft
android:drawableRight
<RelativeLayout 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"
>
<TextView
android:id="@+id/tv01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"
android:textColor="#aa0000"
android:textSize="25sp"
android:textStyle="bold|italic"
android:singleLine="true"
android:drawableTop="@drawable/abc_ic_voice_search"
/>
<TextView
android:id="@+id/tv02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/phone"
android:layout_below="@+id/tv01"
android:autoLink="phone"
/>
<TextView
android:id="@+id/tv03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/web"
android:layout_below="@+id/tv02"
android:autoLink="web"
/>
<TextView
android:id="@+id/tv04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/email"
android:layout_below="@+id/tv03"
android:autoLink="email"
/>
</RelativeLayout>