
上QQ阅读APP看书,第一时间看更新
2.1.2 帧布局
它里面的子控件默认都会放在布局的左上角位置,而如果有多个子控件要放置,则后一个控件会覆盖在前一个控件上:

在这里,定义了两个TextView,分别是“Hello”和“Hello World”,布局的效果如图2.2所示。

图2.1 LinearLayout的布局效果

图2.2 FrameLayout的布局效果
能清楚看到TextView上的文字变成“Hello World”,而且“Hello”明显比“World”要深色一点,说明了布局文件中第二个的TextView是覆盖在第一个TextView上了。
当然,如果想要改变子控件的位置,可以利用那些常用的位置属性如android:layout_gravity=“left”或者android:layout_marginLeft=“数字”等放置到想要放的位置上。