日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

关于Layout Weight一些使用技巧

發布時間:2025/3/15 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 关于Layout Weight一些使用技巧 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

LinearLayout中通過layout weight屬性來表示這個孩子視圖view在整個手機屏幕占的大小比例。

一般不在孩子視圖里面寫這個屬性的時候,則默認為0

android:layout_weight="0"

For example, if there are three text fields and two of them declare a weight of 1, while the other is given no weight, the third text field without weight will not grow and will only occupy the area required by its content. The other two will expand equally to fill the space remaining after all three fields are measured. If the third field is then given a weight of 2 (instead of 0), then it is now declared more important than both the others, so it gets half the total remaining space, while the first two share the rest equally.


比如,如果一個LinearLayout有3個text的孩子視圖,其中2個聲明layout_weight=1;另外一個沒有聲明,即默認為0,占用的空間大小應該和它的內容一樣。那么這2個聲明了為1的,就平分剩下的空間。

如果第3個聲明不是默認為0而是1的話,那么第3個聲明占用了全部空間的一半,另外2個聲明了1的平分另外的一半.

看下面一個例子:

<?xml?version="1.0"?encoding="utf-8"?> <LinearLayout?xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:paddingLeft="16dp"android:paddingRight="16dp"android:orientation="vertical"?><EditTextandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:hint="@string/to"?/><EditTextandroid:layout_width="fill_parent"android:layout_height="0dp"android:layout_weight="1"android:hint="@string/subject"?/><EditTextandroid:layout_width="fill_parent"android:layout_height="0dp"android:layout_weight="1"android:gravity="top"android:hint="@string/message"?/><Buttonandroid:layout_width="100dp"android:layout_height="wrap_content"android:layout_gravity="top"android:text="@string/send"?/> </LinearLayout>


上面運行的結果如下:

明顯to和send所在的區域,因為默認layout_weight不顯示;所以大小默認為0,占用的空間為內容大小。

其他的2個edit平均占用剩下的空間。

關于

?android:layout_height="0dp"android:layout_weight="1"

為什么藥這樣設置,可以看文檔上面的這段話:



Equally weighted children

To create a linear layout in which each child uses the same amount of space on the screen, set theandroid:layout_height?of each view to?"0dp"?(for a vertical layout) or theandroid:layout_width?of each view to?"0dp"?(for a horizontal layout). Then set the?android:layout_weight?of each view to?"1".



轉載于:https://my.oschina.net/liangzhenghui/blog/192361

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的关于Layout Weight一些使用技巧的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 天堂精品视频 | 日日夜夜网站 | 最好看的电影2019中文字幕 | 久久人人爽人人爽人人片亚洲 | 日本国产精品 | 99久久久无码国产精品性青椒 | 国产精品久久二区 | 久久久啊啊啊 | 乱老熟女一区二区三区 | 国产传媒专区 | 伊人久久久久久久久久 | 韩国毛片一区二区 | 亚洲免费激情视频 | 少妇一级淫片免费观看 | 亚洲美女在线观看 | 内射毛片内射国产夫妻 | 最新国产网址 | a视频免费观看 | 毛片传媒| 国产青草| 欧美一级片播放 | 久久久久久久久久久久国产精品 | 亚洲人xxx | 日韩精品无码一区二区三区久久久 | xxxxx69| 无码黑人精品一区二区 | 怡红院一区二区三区 | 成人性生交视频免费观看 | 色91精品久久久久久久久 | 亚洲一区二区三区在线播放 | 夜夜操夜夜爱 | 欧美 日韩 国产 中文 | 对白超刺激精彩粗话av | 亚洲欧洲天堂 | 久久午夜av | 特级一级片 | 亚洲一级黄色片 | 韩国一区视频 | 免费观看的av | 麻豆视频在线观看 | 日本精品免费视频 | 一区精品二区国产 | 亚洲精品资源在线 | 日本a级片在线播放 | 日韩美女视频一区二区 | 伊人亚洲影院 | 日韩一区二区免费播放 | 91人人视频 | 伊人av网站 | 校园伸入裙底揉捏1v1h | 成人欧美一区二区三区在线播放 | 成人在线激情 | 成人一区二区三区仙踪林 | 色噜噜狠狠狠综合曰曰曰88av | 91福利在线观看 | 狠狠干天天操 | 欧洲一区在线 | 久久er99热精品一区二区 | 日韩综合网站 | 欧美人与动性xxxxx杂性 | 7777av| 在线三级av | 日韩精品色 | 又色又爽又黄 | 69久久久久久 | 性少妇xxxxx 亚洲一卡二卡在线观看 | 鲁鲁久久 | 日韩成人综合网 | 日韩欧美一级片 | 男人的天堂亚洲 | 免费在线色视频 | 性欧美精品男男 | 亚洲黄色在线观看 | 国产96视频| 欧美综合专区 | 91综合色 | 丰满秘书被猛烈进入高清播放在 | 亚洲综合在线成人 | 奇米中文字幕 | 久草福利在线视频 | 国产无套在线观看 | 亚洲夜夜夜| 永久免费在线观看视频 | 免费av网站在线观看 | 三级黄色在线视频 | 午夜精品美女久久久久av福利 | www.精品一区 | 综合网亚洲 | 国产精品伦一区 | 国产精品国产一区二区三区四区 | 国产99对白在线播放 | 日韩一级免费毛片 | 日本黄动漫 | 久久久久久成人精品 | 国产美女视频网站 | 欧美性白人极品1819hd | 性色视频在线观看 | 国产成人自拍视频在线 | 国产全肉乱妇杂乱视频 |