欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android 表格布局TableLayout示例詳解

 更新時間:2016年08月08日 16:30:00   作者:chino  
本文主要介紹Android TableLayout布局,這里整理了TableLayout的資料,并附示例代碼和實(shí)現(xiàn)效果圖,有興趣的小伙伴可以參考下

一、表格布局 TableLayout

表格布局TableLayout以行列的形式管理子元素,每一行是一個TableRow布局對象,當(dāng)然也可以是普通的View對象,TableRow離每放一個元素就是一列,總列數(shù)由列數(shù)最多的那一行決定。

我們看一個例子:

<?xml version=”1.0″ encoding=”utf-8″?>
<TableLayout android:id=”@+id/TableLayout01″
android:layout_width=”fill_parent” android:layout_height=”fill_parent”
android:stretchColumns=”0″ xmlns:android=”http://schemas.android.com/apk/res/android”><TableRow android:layout_width=”fill_parent”
android:layout_height=”20dip”>
<TextView android:text=”色彩透明度測試” android:textSize=”18dip”
android:layout_span=”2″ 合并兩列
android:layout_gravity=”center”
android:layout_width=”fill_parent” android:layout_height=”fill_parent”>
</TextView>

在看下顯示效果圖:

其中 android:stretchColumns=”0″ 作用是讓第一列可以擴(kuò)展到所有可用空間;下面我們講一下TableLayout幾個重要的屬性:

  1. collapseColumns – 設(shè)置隱藏那些列,列ID從0開始,多個列的話用”,”分隔
  2. stretchColumns – 設(shè)置自動伸展那些列,列ID從0開始,多個列的話用”,”分隔
  3. shrinkColumns -設(shè)置自動收縮那些列,列ID從0開始,多個列的話用”,”分隔

可以用”*”來表示所有列,同一列可以同時設(shè)置為shrinkable和stretchable。

我們再舉一個例子來看一下:

<?xml version=”1.0″ encoding=”utf-8″?>
<TableLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
android:stretchColumns=”1″>  第二列自動伸展<TableRow>
<TextView
android:layout_column=”1″   我是第二列
android:text=”打開…”
android:padding=”3dip” /> 元素內(nèi)容與邊界之間保留3dip的距離
<TextView
android:text=”Ctrl-O”
android:gravity=”right”
android:padding=”3dip” />
</TableRow><TableRow>
<TextView
android:layout_column=”1″
android:text=”保存…”
android:padding=”3dip” />
<TextView
android:text=”Ctrl-S”
android:gravity=”right” 元素本身的內(nèi)容向右對齊
android:padding=”3dip” />
</TableRow><TableRow>
<TextView
android:layout_column=”1″
android:text=”另存為…”
android:padding=”3dip” />
<TextView
android:text=”Ctrl-Shift-S”
android:gravity=”right”
android:padding=”3dip” />
</TableRow><View
android:layout_height=”2dip”
android:background=”#FF909090″ /><TableRow>
<TextView
android:text=”X”
android:padding=”3dip” />
<TextView
android:text=”導(dǎo)入…”
android:padding=”3dip” />
</TableRow><TableRow>
<TextView
android:text=”X”
android:padding=”3dip” />
<TextView
android:text=”導(dǎo)出…”
android:padding=”3dip” />
<TextView
android:text=”Ctrl-E”
android:gravity=”right”
android:padding=”3dip” />
</TableRow><View
android:layout_height=”2dip”
android:background=”#FF909090″ /><TableRow>
<TextView
android:layout_column=”1″
android:text=”退出”
android:padding=”3dip” />
</TableRow>
</TableLayout>

下面是顯示效果圖:

我加粗顯示的地方都有解釋,大家可以留意一下。

Tip:TableRow也是一個Layout,里面的元素會水平排列,如果TableRow的父元素不是TableLayout的話,那么他會表現(xiàn)的像一個LinearLayout。

以上就是Android TableLayout 布局的資料,后續(xù)繼續(xù)補(bǔ)充相關(guān)資料,謝謝大家對本站的支持!

相關(guān)文章

  • Android手勢密碼view學(xué)習(xí)筆記(一)

    Android手勢密碼view學(xué)習(xí)筆記(一)

    這篇文章主要為大家詳細(xì)介紹了Android手勢密碼view的學(xué)習(xí)筆記,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-03-03
  • Android 應(yīng)用簽名的兩種方法

    Android 應(yīng)用簽名的兩種方法

    這篇文章主要介紹了Android 應(yīng)用簽名的兩種方法的相關(guān)資料,這里提供了兩種實(shí)現(xiàn)方法分別實(shí)現(xiàn)簽名,希望能幫助到大家,需要的朋友可以參考下
    2017-08-08
  • Android仿優(yōu)酷視頻的懸浮窗播放效果

    Android仿優(yōu)酷視頻的懸浮窗播放效果

    這篇文章主要介紹了Android仿優(yōu)酷視頻的懸浮窗播放效果,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-07-07
  • Android封裝的http請求實(shí)用工具類

    Android封裝的http請求實(shí)用工具類

    提供一個Android封裝的http請求實(shí)用工具類,在做ANDROID網(wǎng)絡(luò)開發(fā)中這個經(jīng)常要用到,大家可以參考下面的工具類修改成自己的工具
    2013-11-11
  • Android自定義ScrollView實(shí)現(xiàn)阻尼回彈

    Android自定義ScrollView實(shí)現(xiàn)阻尼回彈

    這篇文章主要為大家詳細(xì)介紹了Android自定義ScrollView實(shí)現(xiàn)阻尼回彈,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-04-04
  • Android之日期及時間選擇對話框用法實(shí)例分析

    Android之日期及時間選擇對話框用法實(shí)例分析

    這篇文章主要介紹了Android之日期及時間選擇對話框用法,以實(shí)例形式較為詳細(xì)的分析了Android創(chuàng)建日期及時間選擇對話框的實(shí)現(xiàn)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-09-09
  • Android 進(jìn)度條自動前進(jìn)效果的實(shí)現(xiàn)代碼

    Android 進(jìn)度條自動前進(jìn)效果的實(shí)現(xiàn)代碼

    這篇文章主要介紹了Android 進(jìn)度條自動前進(jìn)效果,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-07-07
  • 詳解Android應(yīng)用main函數(shù)的調(diào)用

    詳解Android應(yīng)用main函數(shù)的調(diào)用

    Android常識,App主線程初始化了Looper,調(diào)用prepare的地方是ActivityThread.main函數(shù)。問題來了,App的main函數(shù)在哪兒調(diào)用,下面我們來一起學(xué)習(xí)一下吧
    2019-06-06
  • Android顏色配置器配置方法

    Android顏色配置器配置方法

    這篇文章主要介紹了Android顏色配置器配置方法,非常不錯,具有參考解決價(jià)值,需要的朋友可以參考下
    2018-04-04
  • kotlin 定義接口并實(shí)現(xiàn)回調(diào)的例子

    kotlin 定義接口并實(shí)現(xiàn)回調(diào)的例子

    這篇文章主要介紹了kotlin 定義接口并實(shí)現(xiàn)回調(diào)的例子,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-03-03

最新評論