新聞中心
1、gravity

東昌府ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書(shū)未來(lái)市場(chǎng)廣闊!成為創(chuàng)新互聯(lián)的ssl證書(shū)銷(xiāo)售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18980820575(備注:SSL證書(shū)合作)期待與您的合作!
gravity 這個(gè)英文單詞是重心的意思,在這里就表示??课恢玫囊馑肌?/p>
Android:gravity是對(duì)元素本身說(shuō)的,元素本身的文本顯示在什么地方靠著換個(gè)屬性設(shè)置,不過(guò)不設(shè)置默認(rèn)是在左側(cè)的。
android:layout_gravity是相對(duì)與它的父元素說(shuō)的,說(shuō)明元素顯示在父元素的什么位置。
比如說(shuō)button: android:layout_gravity 表示按鈕在界面上的位置。 android:gravity表示button上的字在button上的位置。
可選值:top、bottom、left、right、center_vertical、fill_vertical、center_horizontal、fill_horizontal、center、fill、clip_vertical。
而且這些屬性是可以多選的,用“|”分開(kāi),默認(rèn)這個(gè)的值是:Gravity.LEFT
2、layout_weight
layout_weight 用于給一個(gè)線性布局中的諸多視圖的重要度賦值。
所有的視圖都有一個(gè)layout_weight值,默認(rèn)為零,意思是需要顯示多大的視圖就占據(jù)多大的屏幕空間。若賦一個(gè)高于零的值,則將父視圖中的可用空間分割,分割大小具體取決于每一個(gè)視圖的layout_weight 值以及該值在當(dāng)前屏幕布局的整體 layout_weight值和在其它視圖屏幕布局的layout_weight值中所占的比率而定。
舉個(gè)例子:比如說(shuō)我們?cè)?水平方向上有一個(gè)文本標(biāo)簽和兩個(gè)文本編輯元素。
該文本標(biāo)簽并無(wú)指定layout_weight值,所以它將占據(jù)需要提供的最少空間。如果兩個(gè)文本編輯元素每一個(gè)的layout_weight值都設(shè)置為1,則兩者平分在父視圖布局剩余的寬度(因?yàn)槲覀兟暶鬟@兩者的重要度相等)。如果兩個(gè)文本編輯元素其中***個(gè)的layout_weight值設(shè)置為1,而第二個(gè)的設(shè)置為2,
則剩余空間的三分之二分給***個(gè),三分之一分給第二個(gè)(數(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="" />
網(wǎng)頁(yè)題目:Android程序開(kāi)發(fā)基礎(chǔ)之——頁(yè)面布局
文章出自:http://www.dlmjj.cn/article/dhiophs.html


咨詢
建站咨詢
