Android 之 View ViewGroup

Activity -> View

首先知道:各种布局是可以嵌套的

几个常用布局:
帧布局FrameLayout
线性布局LinearLayout
绝对布局AbsoluteLayout
相对布局RelativeLayout
表格布局TableLayout

FrameLayout 帧布局 
是最简单的一个布局对象。在他里面的的所有显示对象爱你过都将固定在屏幕的左上角,不能指定位置,但允许有多个显示对象,只是后一个会直接覆盖在前一个之上显示,会把前面的组件部分或全部挡住。

LinearLayout
可以让它的子元素垂直或水平的方式排成一行(不设置方向的时候默认按照垂直方向排列)。

AbsoluteLayout
又可以叫做坐标布局,可以直接指定子元素的绝对位置,这种布局简单直接,直观性强,但是由于手机屏幕尺寸差别比较大,使用绝对定位的适应性会比较差。

android:orientation="vertical"
此属性确定了LinearLayout的方向,其值可以为
*vertical, 表示垂直布局
*horizontal, 表示水平布局
android:layout_width="fill_parent"   
android:layout_height="fill_parent"
分别指明了在父控件中当前控件的宽和高,可以设定其确定的值,但一般使用下面两个值
*fill_parent,填满父控件的空白
*wrap_content,表示大小刚好足够显示当前控件里的内容
android:gravity="center_horizontal"
如果是没有子控件的view设置此属性,表示内容的对齐方式;如果是有子控件的view设置此属性,则表示子控件的对齐方式(重力倾向),其值如下(需要多个时,用“|”分开)
*top
*bottom
*left
*right
*center_vertical
*center_horizontal
*center
*fill_vertical
*fill_horizontal
*fill
不用具体讲解,通过字面意思大家应该能看明白这是什么意思。

android:gravity

Specifies how to align the text by the view's x- and/or y-axis when the text is smaller than the view. 
当字符小于view时,如何按照 view's x- and/or y-axis对齐文本

android:layout_gravity
Standard gravity constant that a child can  supply to its parent. [flag]

你可能感兴趣的:(android,layout,手机)