導航:首頁 > 操作系統 > android線性布局

android線性布局

發布時間:2022-04-28 07:09:11

⑴ 在安卓中什麼是線性布局,表格布局,相對布局求詳細答案,急急急!!!!

線性布局(LinearLayout):在該標簽下的所有子元素會根據orientation屬性的值來決定是按行或者是按列來逐個顯示。代碼示例如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name" />

<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />

<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/test" />

</LinearLayout>
而相對布局,則是根據控制項的相對位置而言,比如居於按鈕的左側或者右側,示例如下:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/button1"
android:layout_alignTop="@id/button1"
android:text="@string/hello_world" />

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="@string/app_name" />

</RelativeLayout>
分享

⑵ Android中常用的五種布局

Android
布局是應用界面開發的重要一環,在Android中,共有五種布局方式分別是:
線性布局:LinerLayout
表格布局:TableLayout
相對布局:RelativeLayout
絕對布局:AbsoluteLayout
幀布局:FrameLayout

⑶ Android線性布局和表格布局及其相對布局 都適用於哪些場景

線性布局適用於控制項呈線性排列場景(一個接著一個),此線性可以為橫向的線性與縱向的線性。
表格布局適用於控制項呈表格狀分布,如m行n列,像HTML中的表單。
相對布局適用於另一控制項或父控制項,如在某個控制項的左(右、上、下、中線對齊)或相對於父控制項左(右、上、下、中線對齊)。

布局是可以互相嵌套的,如父控制項(容器)是線性縱向布局,第一個子布局為相對,第二個是表格,第三個是線性...

Android布局的概念是從Swing及HTML的布局引申而來,與他們的排版都非常相似。

Android中還有一種絕對布局,與HTML中的DIV也非常相似,都是以絕對坐標定位的方式定位控制項,但這種布局難以匹配Android不同的屏幕尺寸及不同解析度,所以使用很少。

⑷ android 中線性布局怎樣使控制項居最右邊

在控制項中使用android:layout_gravity="right"

在線性布局中使用android:gravity="right"

前提條件是你的線性布局是vertical

否則就要用其他手段weight等

⑸ android的線性布局裡有幾個按鈕,怎樣控制按鈕之間的間距啊

線性布局裡面有兩種情況,
1、垂直布局:在每個按鈕上加上
//這個表示距上個控制項5dp距下個控制項5dp,相當於在上下各加了5dp的空白區域
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
2、水平布局:在每個按鈕上加上
//這個表示距左邊的控制項5dp距右邊的控制項5dp,相當於在左右各加了5dp的空白區域
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"

⑹ android 用線性布局還是相對布局好

線性布局(LinearLayout):在該標簽下的所有子元素會根據orientation屬性的值來決定是按行或者是按列來逐個顯示。代碼示例如下: <LinearLayout xmlns:android="schemas/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/app_name" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /> <Button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/test" /> </LinearLayout> 而相對布局,則是根據控制項的相對位置而言,比如居於按鈕的左側或者右側,示例如下: <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent"> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/button1" android:layout_alignTop="@id/button1" android:text="@string/hello_world" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:text="@string/app_name" /> </RelativeLayout>

閱讀全文

與android線性布局相關的資料

熱點內容
西安軟體公司程序員鼓勵師 瀏覽:133
預制樁的加密區怎麼區分 瀏覽:84
ea安裝游戲選擇文件夾 瀏覽:870
linuxapache負載均衡配置 瀏覽:649
pac文件編譯軟體 瀏覽:711
基於51單片機的電子時鍾設計 瀏覽:846
手機屏幕解壓的小游戲 瀏覽:749
gcc編譯手冊pdf 瀏覽:588
梁箍筋未標注加密區 瀏覽:629
自家網路連不上上面顯示加密 瀏覽:388
編譯後無法運行圖片 瀏覽:594
linux系統修改文件命令 瀏覽:704
iphone如何安裝中國石化app 瀏覽:179
app怎麼寫簡歷 瀏覽:681
金蝶kis雲app怎麼樣 瀏覽:708
cad命令xr 瀏覽:296
f如何設置ftp伺服器 瀏覽:833
編程題兔子生兔子python 瀏覽:421
加密數字卡專利申請 瀏覽:783
我的世界命令方塊該怎麼拿 瀏覽:785