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

熱點內容
多餘app是怎麼兌換皮膚的 瀏覽:552
sql資料庫查詢表命令 瀏覽:551
簡單音樂網站源碼 瀏覽:644
運動健康app華為手錶怎麼連接 瀏覽:748
肌肉塑造全書pdf下載 瀏覽:796
安卓簡約拼圖用什麼軟體好 瀏覽:289
fx1n加密程序 瀏覽:844
淘客阿里雲伺服器 瀏覽:476
100壓縮打造 瀏覽:422
安卓手機怎麼和蘋果平板傳文件 瀏覽:973
開始選項卡中的頁眉和頁腳命令選項 瀏覽:424
pdf的字體怎麼改 瀏覽:856
python讀寫視頻 瀏覽:88
科魯茲壓縮機軸承 瀏覽:353
word文檔轉換成pdf文件找不到 瀏覽:27
組件注冊命令 瀏覽:760
安卓大屏導航用的是什麼運放 瀏覽:443
myandroidtools的備份 瀏覽:900
python爬蟲天氣預報 瀏覽:761
android70許可權管理 瀏覽:749