亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

Android Layout之三:Linear Layout

系統(tǒng) 2120 0

?

Android Layout之三:Linear Layout

?

轉(zhuǎn)載自: http://android.blog.51cto.com/268543/298345

?

線形布局

?? ?? orientation - 容器內(nèi)元素的排列方式。vertical: 子元素們垂直排列,horizontal: 子元素們水平排列。在代碼里可通過setOrientation()進(jìn)行動態(tài)改變,值分別為HORIZONTAL或者VERTICAL。
?? ? * 在Linear Layout, ?寬度/高度都是按著組件的次序逐個(gè)占用的!所以當(dāng)某個(gè)組件設(shè)置"fill_parent",在沒有設(shè)置Layout_weight的情況下,該組件會占用了余下的空間,那么在它后面的組件就會顯示不出來。如下圖的EditText如果沒有設(shè)置android:layout_weight="1", 它下面的其他組件就看不見了!
?
?? ? baselineAligned 一般情況下,這個(gè)屬性默認(rèn)為true,代表在同一方向的組件都基于第一個(gè)組件對齊。所以可以看到下圖的text1, button1, text2是在同一水平線的。當(dāng)不需要這效果時(shí),可以設(shè)置為false。
main.xml配置內(nèi)容:
        <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView         
	android:text="This is a example of linear layout."         
	android:layout_width="fill_parent"          
	android:layout_height="wrap_content"          
	/>     
<EditText         
	android:layout_width="fill_parent"         
	android:layout_height="fill_parent"         
	android:layout_weight="1"         
	android:id="@+id/edittext"         
	/>      
<LinearLayout         
	android:id="@+id/LinearLayout01"          
	android:layout_width="fill_parent"          
	android:layout_height="wrap_content"          
	android:orientation="horizontal"
	>         
	<TextView              
		android:text="text1"              
		android:id="@+id/TextView01"              
		android:layout_width="wrap_content"              
		android:layout_height="wrap_content"             
		/>         
	<Button 
		android:text="Button01"              
		android:id="@+id/Button01"              
		android:layout_width="fill_parent"              
		android:layout_height="wrap_content"             
		android:layout_weight="1"             
		/>         
	<TextView              
		android:text="text2"              
		android:id="@+id/TextView02"              
		android:layout_width="wrap_content"              
		android:layout_height="wrap_content"             
		/>     
</LinearLayout>      
<TextView         
	android:layout_width="wrap_content"         
	android:layout_height="wrap_content"         
	android:text="buttom"         
/> 
</LinearLayout>

      
?
結(jié)果如下圖:

Android Layout之三:Linear Layout
?

?

?

如果將main.xml配置內(nèi)容中:

    <EditText         
	android:layout_width="fill_parent"         
	android:layout_height="fill_parent"         
	android:layout_weight="1"         
	android:id="@+id/edittext"         
	/> 
  

?

更改為:

?

    <EditText         
	android:layout_width="fill_parent"         
	android:layout_height="fill_parent"         
	android:layout_weight="0"         
	android:id="@+id/edittext"         
	/> 
  

?

或者:

    <EditText         
	android:layout_width="fill_parent"         
	android:layout_height="fill_parent"                 
	android:id="@+id/edittext"         
	/> 
  

?

那么,結(jié)果如下圖:

?


Android Layout之三:Linear Layout
?

?

發(fā)現(xiàn)組件edittext將下面的組件全部擋住了,這其中就數(shù)屬性 【 layout_weight 】導(dǎo)致的。

?

layout_weight - 重要度

?? ? 個(gè)人理解為顯示的優(yōu)先級。默認(rèn)為0(最高),數(shù)值越大,優(yōu)先級越低!參考下面的Linear Layout例子。要讓layout_weight生效,需要父層或父父層的相應(yīng)layout_width/layout_height = "fill_parent!

?

?

Android Layout之三:Linear Layout


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦?。?!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 久草精品在线播放 | 99尹人香蕉国产免费天天在线 | 日日摸夜夜爽日日放碰 | 日韩精品久久久久久 | 欧美成人毛片免费网站 | 欧美性猛交99久久久久99 | 一级一级一级一级毛片 | xxxx成年视频免费 | 色综合久久久高清综合久久久 | 久草成人 | 91国视频 | 黄色小视频免费看 | 妇女毛片 | 亚洲日本va | 久久天天躁综合夜夜黑人鲁色 | 一 级 黄 色 片生活片 | 亚州激情视频在线播放 | 久久精品国产精品青草图片 | 我想看一级毛片免费的 | 久久精品资源站 | 26uuu在线观看 | 中国一级毛片录像 | 亚洲综合一二三 | 999福利视频 | 91国在线 | 久久99精品视香蕉蕉 | 伊人网99 | 香蕉在线视频网站 | 日韩一区二区三区视频在线观看 | aaa级片| 麻豆精品一区二区三区免费 | 精品哟哟国产在线观看 | 成人久久18免费网站游戏 | 国产亚洲综合精品一区二区三区 | 国产欧美日韩精品a在线观看高清 | 欧美在线视频一区二区三区 | 国产91在线精品 | 国内精品伊人久久久久7777人 | 亚洲天天在线日亚洲洲精 | 99热最新在线观看 | 在线看日本吃奶孕交 |