.Net程式員玩轉Android開發---(8)表格版面配置TableLayout

來源:互聯網
上載者:User

標籤:android開發   tablelayout   布局   遊響雲停工作室   移動端開發   

               表格布局TableLayout是Android中比較常用的一個布局控制項,既然是表格,肯定有行和列,TableLayout中的行有TableRow組成,列根據每行控制項的數量來確定

假如第一行有3個控制項,第2行有4個控制項,那麼這個表格的列數就去最大列數,即4列。

               1.屬性介紹

                表格有以下幾個重要屬性

                   android:shrinkColumns="2" 自動收縮的列,多個列用逗號隔開,自動收縮的意思是如果該列的內容超出了表格列的寬度,自動向下顯示

                  android:stretchColumns="1" 自動調整列,多個列用逗號隔開,如果表格中所有列,都沒有佔滿表格寬度,該列自動調整。

                   android:collapseColumns   隱藏指定的列,多個列用逗號隔開

                  android:layout_column="1" 用來設定該表格中控制項所在的列數,

                 android:layout_span  用來設定表格中控制項所佔的列數

                     

<?xml version="1.0" encoding="utf-8"?><TableLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"     android:shrinkColumns="2"    android:stretchColumns="1"    >    <TableRow        android:id="@+id/tableRow1"        android:layout_width="wrap_content"        android:layout_height="wrap_content" >        <TextView            android:id="@+id/textView1"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="標籤1"             android:background="#FF82AB"            />        <TextView            android:id="@+id/textView2"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="標籤2"               android:background="#EE6A50"            />        <TextView            android:id="@+id/textView3"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="我是自動調整列,內容過多,自動向下伸縮"               android:background="#B3EE3A"            />    </TableRow>         <TableRow        android:id="@+id/tableRow1"        android:layout_width="wrap_content"        android:layout_height="wrap_content" >        <TextView            android:id="@+id/textView4"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="標籤4"             android:background="#FF82AB"            />        <TextView            android:id="@+id/textView5"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="自動伸張"               android:background="#EE6A50"            />        <TextView            android:id="@+id/textView6"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="標籤6"               android:background="#B3EE3A"            />    </TableRow></TableLayout>

              2.商品列表示例




.Net程式員玩轉Android開發---(8)表格版面配置TableLayout

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.