導航:首頁 > 操作系統 > 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線性布局相關的資料

熱點內容
壓縮機型號v代表什麼 瀏覽:50
旅遊類源碼 瀏覽:860
電腦伺服器類型怎麼設置 瀏覽:228
pdf炒股 瀏覽:784
伺服器地址缺少埠號什麼意思 瀏覽:528
下載需要解壓的小說用哪個軟體 瀏覽:532
廣東分布式伺服器雲主機 瀏覽:581
伺服器忙打不開怎麼辦 瀏覽:13
tif壓縮軟體 瀏覽:412
程序員那麼可愛陸漓上班第1天 瀏覽:950
macbookair自帶什麼app 瀏覽:700
如何關了加密的軟體 瀏覽:581
程序員p2p待遇 瀏覽:922
ipd編譯要求 瀏覽:936
壓縮解壓王怎麼用 瀏覽:34
伺服器共享文件如何備份 瀏覽:758
買安卓手機怎麼在官網買 瀏覽:126
詩詞入門PDF 瀏覽:365
毒app是什麼單位 瀏覽:67
如何自己編譯android系統 瀏覽:796