惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
The GitHub Blog
The GitHub Blog
C
Check Point Blog
博客园_首页
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
F
Full Disclosure
Microsoft Security Blog
Microsoft Security Blog
爱范儿
爱范儿
Recent Announcements
Recent Announcements
阮一峰的网络日志
阮一峰的网络日志
G
GRAHAM CLULEY
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Threat Research - Cisco Blogs
C
Cybersecurity and Infrastructure Security Agency CISA
V
Vulnerabilities – Threatpost
K
Kaspersky official blog
博客园 - 司徒正美
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
Project Zero
Project Zero
云风的 BLOG
云风的 BLOG
Cisco Talos Blog
Cisco Talos Blog
Know Your Adversary
Know Your Adversary
雷峰网
雷峰网
V
V2EX - 技术
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Spread Privacy
Spread Privacy
罗磊的独立博客
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
SecWiki News
SecWiki News
Schneier on Security
Schneier on Security
O
OpenAI News
Jina AI
Jina AI
PCI Perspectives
PCI Perspectives
Cyberwarzone
Cyberwarzone
Y
Y Combinator Blog
Apple Machine Learning Research
Apple Machine Learning Research
B
Blog RSS Feed
I
InfoQ
D
Docker
P
Palo Alto Networks Blog
Recorded Future
Recorded Future
M
MIT News - Artificial intelligence
博客园 - Franky
B
Blog
Scott Helme
Scott Helme
博客园 - 叶小钗
D
DataBreaches.Net

博客园 - maoyu417

Size Classes with Xcode 6 Android viewPage notifyDataSetChanged无刷新 android、apple PUSH 异同比较 同一位置(同一个ImageView)显示不同的图片--level-list (转) (Android实战)界面设计注意事项 给C盘减减肥,让你电脑飞一般速度! - maoyu417 用SQL查看字符串ASCII码 解决union不能order by问题 利用sender的Parent获取GridView中的当前行(转载) - maoyu417 gridview固定表头 - maoyu417 - 博客园 将某网站设为主页方法 - maoyu417 - 博客园 DataList分页方法一 - maoyu417 - 博客园 SQL区分大小写——转载 字符串间空格在网页上自动合并 Windows Mobil中解决日期显示不正常的方法 - maoyu417 VS升级序列号及升级方法 a标签变灰且不可用 - maoyu417 ASP.NET读取XML文件4种方法 - maoyu417 超时时间已到。在操作完成之前超时时间已过或服务器未响应。 - maoyu417
LinearLayout android:layout_weight的理解
maoyu417 · 2011-07-19 · via 博客园 - maoyu417

一 不正确的理解

将各个view(BUTTON等)的android:layout_weight 看作比例关系在父VIEW中显示。

二 自己的理解

weight是重要性标识,值越大重要性越强。

重要性越强,意味着占据父VIEW剩余空间的能力越强。剩余空间可能很大也可能很小,甚至没有。

三 举例说明证实自己的理解

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" >

<Button android:layout_weight="1" android:id="@+id/btn_ok" android:layout_width="wrap_content" android:text="Button1111111111111111111111111111111" android:layout_height="wrap_content"></Button>

<Button android:layout_weight="2" android:id="@+id/btn_ok2" android:layout_width="wrap_content" android:text="Button2" android:layout_height="wrap_content"></Button>

<Button android:layout_weight="3" android:id="@+id/btn_ok3" android:layout_width="wrap_content" android:text="Button3" android:layout_height="wrap_content"></Button>

</LinearLayout>

btn_ok3重要性最高,所以它占有父view剩余空间能力最强。父view会先紧着btn_ok和btn_ok2显示,这两个view的显示会按其所需要的内容空间进行显示,剩余无论多大的空间都分配给btn_ok3显示。