FrameLayout is designed to block out an area on the screen to display a single item. Generally, FrameLayout should be used to hold a single child view, because it can be difficult to organize child views in a way that's scalable to different screen sizes without the children overlapping each other. You can, however, add multiple children to a FrameLayout and control their position within the FrameLayout by assigning gravity to each child, using the attribute "android:layout_gravity".
以上是Google api對于FrameLayout的介紹,F(xiàn)rameLayout(幀布局)通常情況下所有的子布局都是顯示在布局的左上角,根據(jù)直接子布局順序依次顯示出來,當然子布局可以通過"android:layout_gravity"屬性來確定自身在父布局的位置。通常情況下,F(xiàn)rameLayout是用來和Fragment聯(lián)合使用的,主要用于在Activity里面加入Fragment(碎片)的。
FrameLayout的屬性
* android:foreground:設置幀布局容器的前景圖像
* android:foregroundGravity:設置前景圖像顯示的位置
FrameLayout也沒有什么特別的屬性,就是以上兩個屬性可能會用到,所謂的前景圖像,就是顯示在所有子布局的控件之前顯示。當然這兩個屬性在其他的父布局中也可以使用的,不過可能使用的場景很少。