日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

TableLayout 表格布局,FrameLaout 帧布局 ,AbsoluteLayout绝对布局的分析

發(fā)布時間:2023/11/27 生活经验 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 TableLayout 表格布局,FrameLaout 帧布局 ,AbsoluteLayout绝对布局的分析 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

這三個布局就放在一起來寫了他們用的比較少,不過為了寫這遍

博客我換特意去復習了下,

第一個表格布局TableLayout

表格布局顧名思義 就是與表格類似,以行,列形式來管理其中的組件的,

它是<TableLayout> 標記定義里面必須有一個<TableRow> 作用是占用一行

語法:

<TableLayout?xmlns:android="http://schemas.android.com/apk/res/android"
? ? ? ? 屬性列表>
? <TableRow 屬性列表>
? ? ? ? ? ? ?組件?
? </TableRow>
?
</TableLayout>

幾個特有的屬性

android:collapseColumns 需要設置被隱藏的列的序列號

android:shrinkColumns ?被收縮的列的序列號

android:stretchColumns 被拉伸的列的序列號

下面寫一段代碼:

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"><TableRowandroid:background="#ff3366" android:layout_width="wrap_content"android:layout_height="wrap_content"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:background="#ff3366"android:text="用戶名:"/> </TableRow><TableRow android:background="#00ff00"android:layout_width="wrap_content"android:layout_height="wrap_content"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="密碼:"/> </TableRow></TableLayout>
效果圖:


這里我設置了2中不同的背景顏色大家看到了嗎,知道我想說什么嗎

這里就提醒一下,

在TableLayout中每一個TableRow代表一行,

TableRow的寬和高

   <TableRow android:background="#00ff00"android:layout_width="wrap_content"android:layout_height="wrap_content">
是固定的無論怎么設置都不會改變,不知道大家是否在意過這一點,也就是做
你不要寬和高也是一樣的,
看下面的代碼我隨意改了下


再看下效果圖


怎么樣,沒有收到什么影響吧。

表格布局就說這么多吧

二 幀布局 FrameLayout

在幀布局中 每增加一個組件 將會創(chuàng)建一個空白的區(qū)域,

默認情況下幀布局從屏幕的左上角(0,0)坐標點開始布局,多個組件層疊排列,

后面的組件覆蓋前面的組件,

語法:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"

?屬性列表>

</FrameLayout>

其特有的屬性

android:foreground 幀布局容器的前景圖像

android:foregroundGravity 前景圖像顯示的位置

資料中顯示幀布局用在游戲開發(fā)中,顯示自定義視圖,我目前開發(fā)中用到的很少

在圖片預覽的時候用到過,其他的地方?jīng)]有怎么用到過。

為了驗證:

多個組件層疊排列,

后面的組件覆蓋前面的組件, 我也寫了一個經(jīng)典的demo

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"><TextViewandroid:layout_width="300dp"android:layout_height="300dp"android:layout_gravity="center"android:background="#cc9900"android:text="小木"/><TextViewandroid:layout_width="200dp"android:layout_height="200dp"android:layout_gravity="center"android:background="#00ff00"android:text="小木"/><TextViewandroid:layout_width="100dp"android:layout_height="100dp"android:layout_gravity="center"android:background="#ff00cc"android:text="小木"/><TextViewandroid:layout_width="50dp"android:layout_height="50dp"android:layout_gravity="center"android:background="#ffffff"android:text="小木"/> </FrameLayout>

效果圖:



三 ?AbsoluteLayout絕對布局

現(xiàn)在幾乎不用了,用了它之后無法再進行適配了,原因嗎?看下他的特點吧

特點:坐標的方式來定位在屏幕上的位置,引起缺乏靈活性,在沒有絕對定位的情況下相比其他類型的布局更難維護

把剛才的代碼拿來看看吧

<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"><TextViewandroid:layout_width="300dp"android:layout_height="300dp"android:layout_gravity="center"android:background="#cc9900"android:text="小木"/><TextViewandroid:layout_width="200dp"android:layout_height="200dp"android:layout_gravity="center"android:background="#00ff00"android:text="小木"/><TextViewandroid:layout_width="100dp"android:layout_height="100dp"android:layout_gravity="center"android:background="#ff00cc"android:text="小木"/><TextViewandroid:layout_width="50dp"android:layout_height="50dp"android:layout_gravity="center"android:background="#ffffff"android:text="小木"/> </AbsoluteLayout>

這個就說這么多吧,我查了下資料說在android2.0之后就標記過期了,

自己也是只有有這么一個布局,不過從來沒有用到實際的項目中。



總結

以上是生活随笔為你收集整理的TableLayout 表格布局,FrameLaout 帧布局 ,AbsoluteLayout绝对布局的分析的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。