android之View
1.继承关系
android.view.ViewGroup 继承自android.view.View , android.view.View 继承自java.lang.Object
2.布局层次
ViewGroup 内部可嵌套view 和ViewGroup ,View 内部不可嵌套.
3.View 的基本属性
android:layout.width=" "//控件的宽度
android:layout_height="" //控件的高度
内部填充:
match_parent //匹配父控件,若无父控件则匹配手机的宽或高
fill_parent //同match_patent ,android2.3版本使用
wrap_content //内容包裹,控件的大小随其内容的大小而变化
"xxdp"//固定宽高,
单位:
控件大小用dp,设备独立像素与硬件相关,dpi = (手机屏幕宽的平方+高的平方)开根号 ÷手机尺寸(对角线)
文字大小设置用sp
android:background = ""//设置背景颜色,常采用#RRGGBB颜色格式
android:id="@+id/XXX"//设置控件id,在gen文件下的R文件自动生成地址,在源代码中可通过id查找控件或引入布局
android:padding="xxdp":外部控件的内边距,
android:paddingLeft=""//左边距
android:paddingRight=""//右边距
android:paddingTop=""//上边距
android:paddingBottom=""//下边距
android:layout_margin="xxdp"//内部控件的外边距
android:layout_marginTop=""
android:layout_marginLeft=""
android:layout_marginRight=""
android:layout_marginBottom=""