public class FrameLayout extends ViewGroup
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 android:layout_gravity
attribute.
//帧布局被设计出来通过在屏幕上封闭一个区域显示一个单独的项目。通常,帧布局被用来控制一个单独的子视图,因为用一种方法组织在不同尺寸的屏幕上可伸缩的子视图而不出现子视图的相互重叠是非常困难的.但是,你可以在一个FrameLayout里面添加不同的子视图并且通过在FrameLayout里面设置每一个子视图的重力来控制它们的位置,通过android:layout_gravity的属性。
Child views are drawn in a stack, with the most recently added child on top. The size of the FrameLayout is the size of its largest child (plus padding), visible or not (if the FrameLayout's parent permits). Views that are GONE
are used for sizing only if setConsiderGoneChildrenWhenMeasuring()
is set to true.
//子视图随着最近被添加的子布局被绘制在栈的顶部.FrameLayout的尺寸是最大子视图的尺寸(加上填充),可见或者不可见的(如果FrameLayout的父布局允许).只有当setConsiderGoneChildrenWhenMeasuring()被设置成true时,Views的GONE被用来测量尺寸。