自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Android程序開發(fā)基礎之——頁面布局

移動開發(fā) Android
Android程序開發(fā)基礎。

1、gravity

gravity 這個英文單詞是重心的意思,在這里就表示停靠位置的意思。

android:gravity是對元素本身說的,元素本身的文本顯示在什么地方靠著換個屬性設置,不過不設置默認是在左側的。

android:layout_gravity是相對與它的父元素說的,說明元素顯示在父元素的什么位置。

比如說button: android:layout_gravity 表示按鈕在界面上的位置。 android:gravity表示button上的字在button上的位置。

可選值:top、bottom、left、right、center_vertical、fill_vertical、center_horizontal、fill_horizontal、center、fill、clip_vertical。

而且這些屬性是可以多選的,用“|”分開,默認這個的值是:Gravity.LEFT

2、layout_weight

layout_weight 用于給一個線性布局中的諸多視圖的重要度賦值。

所有的視圖都有一個layout_weight值,默認為零,意思是需要顯示多大的視圖就占據多大的屏幕空間。若賦一個高于零的值,則將父視圖中的可用空間分割,分割大小具體取決于每一個視圖的layout_weight 值以及該值在當前屏幕布局的整體 layout_weight值和在其它視圖屏幕布局的layout_weight值中所占的比率而定。

舉個例子:比如說我們在 水平方向上有一個文本標簽和兩個文本編輯元素。

該文本標簽并無指定layout_weight值,所以它將占據需要提供的最少空間。如果兩個文本編輯元素每一個的layout_weight值都設置為1,則兩者平分在父視圖布局剩余的寬度(因為我們聲明這兩者的重要度相等)。如果兩個文本編輯元素其中***個的layout_weight值設置為1,而第二個的設置為2,

則剩余空間的三分之二分給***個,三分之一分給第二個(數值越小,重要度越高)。

 

[[73020]]

 

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="@drawable/bg02"

android:orientation="horizontal" >

 

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

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:layout_weight="4"

android:orientation="vertical" >

 

android:id="@+id/txtSpace1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="" />

 

 

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

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:layout_weight="1"

android:orientation="vertical" >

 

android:id="@+id/txtSpace2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="" />

 

android:id="@+id/button1"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="@string/mn_01" />

 

android:id="@+id/button2"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="@string/mn_02" />

 

android:id="@+id/button3"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="@string/mn_03" />

 

android:id="@+id/button4"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="@string/mn_04" />

 

 

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

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:layout_weight="4"

android:orientation="vertical" >

 

android:id="@+id/txtSpace3"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="" />

 

【編輯推薦】

  1. Android 的中長期焦慮?
  2. 風河公司:Android是目前最好的選擇
  3. droid碎片化嚴重:應用商購買400款手機測試

 

責任編輯:冰凝兒 來源: 博客園
相關推薦

2012-05-14 21:14:07

Android頁面?zhèn)髦?/a>

2009-06-09 10:24:35

NetBeansStruts頁面布局

2022-03-28 07:52:31

H5小游戲開發(fā)教程頁面基礎布局

2010-05-22 16:57:09

BlackBerry開

2021-08-12 15:01:09

鴻蒙HarmonyOS應用

2014-12-17 10:12:06

HybridAppFramewor頁面布局

2018-06-08 15:28:31

Android開發(fā)程序

2010-09-03 10:58:45

DIVCSS

2009-08-14 17:08:00

Android應用程序

2016-11-04 10:47:27

微信小程序

2013-01-17 15:51:42

Android開發(fā)應用程序組件

2016-11-04 10:49:48

微信小程序

2011-04-11 17:07:33

布局基礎用戶界面設計Android

2012-12-31 10:36:58

Android開發(fā)RelativeLay布局

2011-07-25 18:32:55

iPad 平板電腦 蘋果

2010-09-14 08:53:06

DIVTable

2017-09-08 16:45:14

移動

2009-07-14 15:42:38

MyEclipse開發(fā)

2012-04-26 22:57:57

Android

2011-05-11 17:05:54

點贊
收藏

51CTO技術棧公眾號