android layout的一些注意事项

1. 最经常使用的布局是LinearLayout,RelativeLayout和FrameLayout 布局

2. gravity属性对于LinearLayout和RelativeLayout有效,对FrameLayout无效 spa

3. laout_gravity属性对于FrameLayout有效,对于LinearLayout内部元素部分有效(和orientation有关,若是是 vertical,则top和bottom无效,反之,则left和right无效),对于RelativeLayout内部元素无效 事件

4. LinearLayout中的layout_weight属性,因为这个属性有点诡异,若是想正常的发挥做用,其 layout_width(orientation=horizontal)或者 layout_height(orientation=vertical)最好设成0dp it

5. margin这个属性,不是上下左右都必定能生效的,通常来讲,左上角的margin能生效,右下角的margin就未必了 io

6.LinearLayout中元素没法直接覆盖,把margin设成负值能够覆盖。 layout

7.RelativeLayout和FrameLayout默认都是从左上角开始一层一层的叠上去的,若是上层不设背景或者背景透明的话,下层的东西仍是能够可见而且能够点击的,即便看不见了,下层的东西也仍是能够被点击到并触发其点击事件 margin

相关文章
相关标签/搜索