android控件01---Textview


Textview可以說是Android中最簡單的一個控件。

下面我們來看一下它的具體用法。


佈局文件中的代碼,如下所示:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"                          //縱向佈局
    android:layout_width="match_parent"            //當前控件大小與父佈局的大小一致
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/textview"                          //唯一標識符
        android:layout_width="match_parent"          
        android:layout_height="wrap_content"        //控件內容決定當前控件大小
        android:gravity="center"                              //字的對齊方式 
        android:textSize="24dp"                              //字體大小
        android:textColor="#ff0"                              //字體顏色
        android:text="This is Textview!"                  //設置顯示的內容

</ Linearlayout>


運行圖如下:


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章