184_wrap和match的发现
来源:互联网 发布:网络大电影投资模式 编辑:程序博客网 时间:2024/05/03 14:39
wrap和match的发现
发现一个现象,算是给了我一点教训
但是也是非常合理的
是这样的
我们在一个LinearLayout里面放一个TextView
<LinearLayout
android:layout_width="wrap_content"
android:orientation="vertical"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:text="text"
android:background="#ff0000"
android:layout_height="wrap_content"/>
</LinearLayout>
我们给外面是wrap,给里面是match
我们发现效果是TextView是小的,也就是wrap的
另外
如果是horizontal的话,也是wrap的
然后我们在一个RelativeLayout里面放一个TextView
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:text="text"
android:background="#00ff00"
android:layout_height="wrap_content"/>
</RelativeLayout>
我们发现这里TextView是match的
为什么LinearLayout和RelativeLayout是不同的
我们来看看两个layout的源码
看看他们是怎么测绘的
我们先看看两个layout的onMeasure方法
非常抱歉
我发现RelativeLayout的onMeasure有300行
LinearLayout更是分了2种
if (mOrientation == VERTICAL) {
measureVertical(widthMeasureSpec, heightMeasureSpec);
} else {
measureHorizontal(widthMeasureSpec, heightMeasureSpec);
}
measureVertical有300行
measureHorizontal有400行
看了很久没有看到关键性的影响子控件的代码
等我有空的时候再看吧
- 184_wrap和match的发现
- Broad Match,Phrase Match和Exact Match的区别
- match的意义和用法
- pattern和match的用法
- match和exec的对比
- 正则exec和match的区别(比较)
- javascript中exec和match的比较
- python 中,match和search的区别
- python的正则匹配,match和find
- ruby中match和scan的用法
- 正则表达式match和findall的区别
- match parent 和 fill parent的区别
- Python里面search()和match()的区别?
- JavaScript里的match和正则表达式
- JavaScript: 常用的match 和search方法
- python题目-----search()和match()的区别
- .test()和.match()方法的异同
- Python正则match()和search()的理解
- 技术小白的学习记录
- 写博客不是为了分享和记录,只是为了自己总结
- C++第7次作业
- C++作业7
- ACM:蓝桥杯:猜年龄
- 184_wrap和match的发现
- C++实验-7
- JavaAPI之RetentionPolicy枚举类
- 使用__wrap_malloc替换malloc查找内存泄漏
- ACM:蓝桥杯:39级台阶
- 185_AS下多渠道打包
- svn working copy locked问题
- 实验七课后作业
- leetcode-Remove Duplicates from Sorted List II-82