帧布局是最为简单的一种布局,该布局为每个加入其中的控件创建一个空白区域,称为一帧,每个控件占据一帧。采用帧布局时,所有控件都默认显示在屏幕左上角,并按照先后放入的顺序重叠摆放,先放入的将会在最底层,后放入的控件显示在最顶层。帧布局使用于图层设计。
属性
foreground :设置帧布局容器的前景图像
foregroundGravity :属性设置图像的显示位置
看代码
<FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:foreground="@mipmap/ic_launcher" android:foregroundGravity="bottom"> <TextView android:id="@+id/textView" android:layout_width="460dp" android:layout_height="336dp" android:background="@color/colorAccent" android:text="TextView" /> <TextView android:id="@+id/textView2" android:layout_width="332dp" android:layout_height="242dp" android:background="@color/colorPrimary" android:text="TextView" /></FrameLayout>
效果图