Comments (10)
代码如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView1"
android:layout_weight="0.5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Weight 0.5"
android:background="#ff0" />
<TextView
android:id="@+id/textView2"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Weight 1"
android:background="#f00"/>
</LinearLayout>
</RelativeLayout>
from google_android_book_v2.
kris大神这个设的有问题,官方文档说了,weight的时候,要么width为零,要么height为零,这种情况下数值越大,权重越大,官方文档是这么写的
发自我的 iPhone
在 2013-6-14,14:23,"Kris.lee" [email protected] 写道:
'''
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:id="@+id/textView1"
android:layout_weight="0.5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Weight 0.5"
android:background="#ff0" /><TextView android:id="@+id/textView2" android:layout_weight="1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Weight 1" android:background="#f00"/>
'''
—
Reply to this email directly or view it on GitHub.
from google_android_book_v2.
@snowxwyo 你是相信眼见为实还是文档 ? 或者你把你的实际效果帖出来征服我
from google_android_book_v2.
他手机,可能不方便吧。再有文档,贴具体的链接。
from google_android_book_v2.
哈哈,weight这个属性比较复杂,两种结果都有可能的,要看布局如何去写。
from google_android_book_v2.
@futurexiong 哦?哪种情况下可以实现weight值越大占的比重越大?
from google_android_book_v2.
最简单的就是width或者height为0嘛
futurexiong
在 2013年6月14日,15:03,"Kris.lee" [email protected] 写道:
@futurexiong 哦?哪种情况下可以实现weight值越大占的比重越大?
—
Reply to this email directly or view it on GitHub.
from google_android_book_v2.
width或height其中一项设置为0dp的时候,weight越大,权重越大,我试过了,但现在没网,只能用手机,发不了截图
发自我的 iPhone
在 2013-6-14,15:03,"Kris.lee" [email protected] 写道:
@futurexiong 哦?哪种情况下可以实现weight值越大占的比重越大?
—
Reply to this email directly or view it on GitHub.
from google_android_book_v2.
@snowxwyo @futurexiong @vincent4j
总结下: (前提是horizontal->width ; vertical ->height)
1.width或height其中一项设置为0dp的时候,weight越大,权重越大
2.width或height其中一项设置为match_parent的时候,weight越大,权重越小
3.width或height其中一项设置为wrap_content的时候,自动适应
from google_android_book_v2.
已经摘录进 wiki,可以 close 掉。
from google_android_book_v2.
Related Issues (20)
- Bug:第268页代码段“DownloadThread的实现"部分,最后一行代码对象mHandler无定义。 HOT 3
- #8# 第86页:onStart() ? onStartCommand() HOT 3
- #12# 12.3源码问题:java.lang.NoClassDefFoundError: com.db4o.Db4oEmbedded HOT 3
- 新版本建议集锦! HOT 2
- #15# 214页,不理解:框架将不会画不在失效区域的视图 HOT 3
- 第1次印刷问题统计 HOT 11
- 第19章,267页,代码排版不对齐:1. Button的监听事件(startScanner()) HOT 1
- hexter 修改 HOT 9
- #13# 代码排版问题:部分代码左对齐 HOT 7
- #4# eoe 全小写的问题 HOT 2
- #10# 源码缺省 HOT 1
- #10# 部分 xml 文件名首字母大写 HOT 2
- 留有 修改 HOT 1
- 规则:如何直接在 Dropbox 上的 doc 文档上进行纠错 HOT 1
- #一印纠错# 尚未完成部分汇总
- #20# eoeWiKI源码还是运行不了? HOT 8
- 发现1处印刷错误 HOT 2
- 12章notepad的源码是不是有问题? HOT 2
- 第十三章的项目eoeWikiRecent中的URL地址是不是改了
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google_android_book_v2.