功能 :向用户展示文本信息
用法 :
一、在mainActivity中加载控件:(在特殊情况下使用)
TextView textView = new TextView(this) ; //创建控件
textView.setText("Hello World !") ; //设置文本
setContentView(textView) ;//加载控件
二、在xml布局文件中布局控件 :(推荐使用)
在 activity——main.xml中写入:
<TextView
android:id="@+id/myTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
三、在TextView中以HTML文本方式显示:
TextView textView = new TextView(this) ; //创建控件
textView.setText(Html.fromHtml("欢迎大家,<font color=blue>来到我的博客</font>")) ; //设置文本