Android初试--Framlayout(帧布局)
FrameLayout是最简单的一个布局对象。它被定制为你屏幕上的一个空白备用区域,之后你可以在其中填充一个单一对象。比如,一张你要发布的图片。所有的子元素将会固定在屏幕的左上角,你不能为该布局中的一个子元素指定一个位置。后一个子元素将会直接在前一个子元素之上进行覆盖填充,把它们部分或全部挡住(除非后一个子元素是透明的)。
我们使用网上的霓虹灯效果案例:
参考:http://www.myexception.cn/android/1397052.html
activity_main.xml布局文件:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<!-- 依次定义6个TextView,先定义的TextView位于底层 -->
<TextView android:id="@+id/text01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:width="320dp"
android:height="320dp"
android:background="#f00"
/>
<TextView android:id="@+id/text02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:width="280dp"
android:height="280dp"
android:background="#0f0"
/>
<TextView android:id="@+id/text03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:width="240dp"
android:height="240dp"
android:background="#00f"
/>
<TextView android:id="@+id/text04"
android:layout_width="wrap_content"
android:layout