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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

android系统五大布局,android 五大布局文件

發布時間:2023/12/19 windows 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android系统五大布局,android 五大布局文件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

android中為了適應各種布局的格式,提供了5種布局格式:

LinearLayout(線性布局)FrameLayout(幀布局)RelativeLayout(相對布局)TableLayout(表格布局)AbsoluteLayout(絕對布局)。

在android的項目中,我們要設計出讓人耳目一新的界面,無時無刻都要用到這些布局格式。這些布局文件主要是以xml文件的格式存在,并且保存在/res/layout目錄下。此文件夾下存著我們寫的各種布局文件。例如:/res/layout/activity_main.xml.

下面我們詳細介紹一下5種布局文件:FrameLayout(幀布局)

此布局是最簡單的布局形式,所添加的組件都是層疊的方式顯示,第一個控件在最底層,最后添加的控件在視圖顯示的最上層,有點類似堆棧的形式。下面給出自己的一個實例:<?xml ?version="1.0"?encoding="utf-8"?>

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@drawable/background"

android:orientation="vertical"?>

android:layout_width="match_parent"

android:layout_height="300dip"

android:orientation="vertical"?>

android:id="@+id/start"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="startAnimation"

/>

android:id="@+id/stop"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="reversestartAnimation"

/>

android:layout_width="match_parent"

android:layout_height="match_parent"?>

android:id="@+id/windmill_layout"

android:layout_width="match_parent"

android:layout_height="80dip"?>

android:id="@+id/im_roof"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center"

android:src="@drawable/windmill_roof"?/>

android:id="@+id/im_fan"

android:layout_width="104dp"

android:layout_height="106dp"

android:layout_gravity="center"

android:src="@drawable/windmill_fan"?/>

android:id="@+id/im_window"

android:layout_width="80dip"

android:layout_height="80dip"

android:layout_alignParentBottom="true"

android:layout_centerHorizontal="true"

android:layout_marginBottom="20dp"

android:src="@drawable/windmill_window"?/>

這是在RelativeLayout中嵌套一個FrameLayout布局。并且FrameLayout布局中有兩個互相重疊的p_w_picpathView對象。

2. AbsoluteLayout(絕對布局)

此布局中的子控件需要指定其坐標的相對位置的橫縱坐標,否則此布局會像FrameLayout布局一樣被排在左上角。此布局不能自動適應屏幕尺寸,所以少用,這里簡單介紹一下定義。

3.TableLayout(表格布局)

定義:把子控件元素放置在行和列中,并且不顯示行列和單元格邊界線。每一行就是一個TableRow,也可以是一個View對象。在TableRow里面每天加一個控件,代表一列。

屬性參數說明:

android:layout_colum :設置控件在TableRow中所處的列。

android: layout_span:設置此控件所跨越的列數。

android:collapseColumns:TableLayout指定的列隱藏,多列隱藏,逗號將隱藏類隔開。

android:StretchColumns:指定的列為可以伸展的列,多列伸展,用逗號隔開。

android:shrinkColmns:設置指定的列為可收縮的列。

4.LinearLayout(線性布局)

定義:在一個方向上(垂直或者水平)對齊所有子元素,一個垂直列表中每一行都只有一個子元素,一個水平列表只是一列高度。<?xml ?version="1.0"?encoding="utf-8"?>

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:gravity="center_vertical"

android:orientation="vertical"?>

android:id="@+id/catalog"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="#E0E0E0"

android:textColor="#454545"

android:layout_weight="1.0"

android:paddingLeft="5dip"

android:paddingTop="5dip"

android:paddingBottom="5dip"

android:text="A"/>

android:id="@+id/title"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:layout_gravity="center_vertical"

android:gravity="center_vertical"

android:layout_weight="1.0"

android:textColor="#336598"

android:layout_marginLeft="5dip"

android:paddingTop="10dip"

android:paddingBottom="10dip"

android:text="hhhh"/>

5.RelativeLayout(相對布局)

定義:根據布局中子控件會根據他們設置的參照控件和參數進行相對布局。參照控件可以是父控件,也可以是其他的子控件,但是被參照的空間必須在參照它的控件之前定義。<?xml ?version="1.0"?encoding="utf-8"?>

android:id="@+id/umeng_socialize_comment_item"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:background="#ffffff"

android:padding="5dp"?>

android:id="@+id/umeng_socialize_comment_item_profile_gp"

android:layout_width="50dp"

android:layout_height="130dp"

android:layout_marginLeft="8dp"

android:gravity="center"?>

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="@null"?/>

android:id="@+id/umeng_socialize_comment_avatar"

android:layout_width="48dp"

android:layout_height="48dp"

android:layout_marginTop="8dp"

android:layout_centerVertical="true"

android:src="@drawable/umeng_socialize_default_avatar"

android:scaleType="fitXY"?/>

android:id="@+id/umeng_socialize_comment_item_name"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginLeft="8dp"

android:layout_marginTop="5dp"

android:layout_toRightOf="@id/umeng_socialize_comment_item_profile_gp"

android:ellipsize="end"

android:ems="10"

android:maxLines="1"

android:textColor="@color/umeng_socialize_list_item_textcolor"

android:textSize="14sp"

/>

android:id="@+id/umeng_socialize_comment_item_content"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginLeft="8dp"

android:layout_marginTop="0dp"

android:layout_toRightOf="@id/umeng_socialize_comment_item_profile_gp"

android:layout_below="@id/umeng_socialize_comment_item_name"

android:maxLength="35"

android:layout_marginRight="18dp"

android:scrollHorizontally="false"

android:ellipsize="end"

android:textColor="#646464"

android:textSize="12sp"?/>

android:id="@+id/umeng_socialize_comment_item_time"

android:layout_marginTop="0dp"

android:layout_marginLeft="8dp"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_below="@id/umeng_socialize_comment_item_content"

android:layout_toRightOf="@id/umeng_socialize_comment_item_profile_gp"

android:textColor="@color/umeng_socialize_text_time"

android:textSize="10sp"?/>

android:id="@+id/umeng_socialize_comment_item_has_location"

android:layout_marginTop="0dp"

android:layout_alignParentRight="true"

android:layout_centerVertical="true"

android:layout_height="18dp"

android:layout_width="18dp"

android:scaleType="fitXY"

android:visibility="invisible"

android:src="@drawable/umeng_socialize_location_ic"/>

相對布局中的屬性參數比較多,也比較重要的布局格式。介紹一下relativeLayout布局的屬性參數:

android:layout_centerHorizontal 水平居中

android:layout_centervertical 垂直居中

android:layout_centerInParent 相對于父元素完全居中

android: layout_alignparentBottom 貼近父元素的下邊緣

android:layout_alignparentLeft

android:layout_alignParentRight

android:layout_alignparentTop

android:layout_alignwithparentifmissing 如果對應的兄弟元素找不到,就以父元素作為參照物

android:layout_below="id/id-name" 在某元素下面

android:layot_top

android:layout_toLeftof

android:layout_toRightof

android:layout_alignTop 本元素的上邊緣和某元素的上邊緣對齊

android:layout_alignBottom

android:layout_alignLeft

android:layout_alignRight

android:layout_marginBottom 離某元素底邊緣的距離

android:layout_margintop

android:layout_marginleft

android:layout_marginright

總結

以上是生活随笔為你收集整理的android系统五大布局,android 五大布局文件的全部內容,希望文章能夠幫你解決所遇到的問題。

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