3.帧布局 (FrameLayout)
说到帧布局, 就比较简单了,而且比较好理解,并且帧布局的用处不是很多,但他的存在还是有他的必要性的。FrameLayout中的Frame和iOS中的Frame不是一个概念,在iOS中的Frame你可以指定任意的坐标,而这个坐标点时相对于父视图的。FrameLayout中的Frame的坐标原点是屏幕的左上角,位置固定,你只需为控件指定大小即可。接下来将通过一个实例来搞一下这个FrameLayout。
下面是使用FrameLayout做的一个效果,可以看出每块区域中除了大小颜色不一样外,他们的坐标点都是左上角的位置。这也是FrameLayout的特点,下面是运行效果截图:
实现上方布局的xml如下:
<RelativeLayout xmlns:android="http://www.easck.com/apk/res/android" xmlns:tools="http://www.easck.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context="com.example.lizelu.userinterfacedemo.MainActivity"> <FrameLayout android:layout_width="pt" android:layout_height="pt" android:background="#ff"> <FrameLayout android:layout_width="pt" android:layout_height="pt" android:background="#ff"> </FrameLayout> <FrameLayout android:layout_width="pt" android:layout_height="pt" android:background="#ff"> </FrameLayout> <FrameLayout android:layout_width="pt" android:layout_height="pt" android:background="#ffff"> </FrameLayout> <FrameLayout android:layout_width="pt" android:layout_height="pt" android:background="#"> </FrameLayout> </FrameLayout> </RelativeLayout>











