您的位置:首页 > 移动开发 > Android开发

Android学习杂记(二)布局

2014-08-30 21:53 399 查看

线性布局和相对布局的一些性质

android:id="@+id/my_button" +指R文件,可以不要 @是指解析器
RelativeLayout是LinearLayout的子类
 ViewGroup.LayoutParam 确定了子视图的高和宽(layout_height,layout_width)
android:layout_height 和 android:width 的属性值有三个:fill_parent, match_parent 和 wrap_content
fill_parent 从Android 2.2开始就用 match_parent 代替了,恰好包括父控件。wrap_content 恰好能包括子控件.
 density-independent pixel units (dp)
 getRight() = getLeft() + getWidth()
 getBottom() = getTop() + getHeight()
 android:padding是里面的内容和父View边界之间的距离 ;android:layout_margin 则是说两个子view边界之间的距离
当超出屏幕后,getMeasuredHeight()等于getHeight()加上屏幕之外没有显示的大小。就是说MeasureHeight是实际设置大小,Height是实际显示大小
 Adapter是Data和View之间的桥梁,man in the middle, 有点像Intent,你定义listView要setAdapter,把数据传进来
 LinearLayout有oritentation属性,他的子视图都是放在栈里的
 android:weight属性很有意思,表示此控件在LinearLayout中的权重
 RelativeLayout比LinearLayout性能好,因为不用嵌套

android:margin和android:padding,前者表示距离父视图的距离,后者表示控件内部的距离。

链接:

谷歌官方文档 layout标签 http://developer.android.com/guide/topics/resources/layout-resource.html
谷歌官方文档 layout入门 http://developer.android.com/guide/topics/ui/declaring-layout.html

安卓布局大全 包括五种经典布局 http://www.cnblogs.com/devinzhang/archive/2012/01/19/2327535.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: