新聞中心
1、gravity

東昌府ssl適用于網(wǎng)站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18980820575(備注:SSL證書合作)期待與您的合作!
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值,默認為零,意思是需要顯示多大的視圖就占據(jù)多大的屏幕空間。若賦一個高于零的值,則將父視圖中的可用空間分割,分割大小具體取決于每一個視圖的layout_weight 值以及該值在當前屏幕布局的整體 layout_weight值和在其它視圖屏幕布局的layout_weight值中所占的比率而定。
舉個例子:比如說我們在 水平方向上有一個文本標簽和兩個文本編輯元素。
該文本標簽并無指定layout_weight值,所以它將占據(jù)需要提供的最少空間。如果兩個文本編輯元素每一個的layout_weight值都設置為1,則兩者平分在父視圖布局剩余的寬度(因為我們聲明這兩者的重要度相等)。如果兩個文本編輯元素其中***個的layout_weight值設置為1,而第二個的設置為2,
則剩余空間的三分之二分給***個,三分之一分給第二個(數(shù)值越小,重要度越高)。
[[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="" />
新聞名稱:Android程序開發(fā)基礎之——頁面布局
文章地址:http://www.5511xx.com/article/dhiophs.html


咨詢
建站咨詢
