Android開發筆記之Linear Layout

來源:互聯網
上載者:User

  LinearLayout是線性布局控制項,它包含的子控制項將以橫向或豎向的方式排列,按照相對位置來排列所有的widgets或者其他的containers,超過邊界時,某些控制項將缺失或消失。因此一個垂直列表的每一行只會有一個widget或者是container,而不管他們有多寬,而一個水平列表將會只有一個行高(高度為最高子控制項的高度加上邊框高度)。LinearLayout保持其所包含的widget或者是container之間的間隔以及互相對齊(相對一個控制項的靠右對齊、中間對齊或者靠左對齊)。

android:id  —— 為控制項指定相應的ID
     android:text —— 指定控制項當中顯示的文字,需要注意的是,這裡盡量使用strings.xml檔案當中的字串
     android:grivity —— 指定控制項的基本位置,比如說置中,居右等位置
     android:textSize —— 指定控制項當中字型的大小
     android:background —— 指定該控制項所使用的背景色,RGB命名法
     android:width —— 指定控制項的寬度
     android:height —— 指定控制項的高度
     android:padding* —— 指定控制項的內邊距,也就是說控制項當中的內容
     android:sigleLine —— 如果設定為真的話,則將控制項的內容在同一行當中進行顯示   

<?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"    >    <!--    android:id  —— 為控制項指定相應的ID    android:text —— 指定控制項當中顯示的文字,需要注意的是,這裡盡量使用strings.xml檔案當中的字串    android:grivity —— 指定控制項的基本位置,比如說置中,居右等位置    android:textSize —— 指定控制項當中字型的大小    android:background —— 指定該控制項所使用的背景色,RGB命名法     android:width —— 指定控制項的寬度    android:height —— 指定控制項的高度    android:padding* —— 指定控制項的內邊距,也就是說控制項當中的內容    android:sigleLine —— 如果設定為真的話,則將控制項的內容在同一行當中進行顯示     --><TextViewandroid:id="@+id/firstText"android:text="第一行"android:gravity="center_vertical"android:textSize="5pt"android:background="#aa0000"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_weight="1"android:textColor="#000000"        android:singleLine="true"/><TextViewandroid:id="@+id/secondText"android:text="第二行"android:gravity="center_vertical"android:textSize="15pt"android:background="#0000aa"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_weight="1"/></LinearLayout>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.