Android开发 第10课 FrameLayout

来源:互联网 发布:剑灵女咒术师捏脸数据 编辑:程序博客网 时间:2024/06/07 02:42

五布局之针布局 FrameLayout

这个布局中,所有的子元素都不能被指定放置的位置,他们统统放于这块区域的左上角,并且后面的子元素直接被覆盖在前面的子元素之上,将前面的子元素部分和去不遮挡

通过调控每一个控件的宽高来实现特殊效果。
帧布局中如何设置前景图使用 android:foreground 设置

哆啦A梦叠加效果实现<?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"><!--设置控件大小-->    <TextView        android:layout_gravity="center"        android:background="@drawable/doraemonsad"        android:id="@+id/textView4"        android:layout_width="300dp"        android:layout_height="300dp"        android:text="第一个页面" />    <TextView        android:layout_gravity="center"        android:background="@drawable/doraemonhappy"        android:id="@+id/textView5"        android:layout_width="250dp"        android:layout_height="250dp"        android:text="第二个页面" />    <TextView        android:layout_gravity="center"        android:background="@drawable/doraemonsad"        android:id="@+id/textView6"        android:layout_width="150dp"        android:layout_height="150dp"        android:text="第三个页面" />    <TextView        android:layout_gravity="center"        android:background="@drawable/doraemonhappy"        android:id="@+id/textView7"        android:layout_width="100dp"        android:layout_height="100dp"        android:text="第四个页面" /></FrameLayout>

这里写图片描述

进度条实现<?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"><!--ProgressBar不能设置文字-->    <ProgressBar        android:layout_gravity="center"        android:id="@+id/progressBar"        style="?android:attr/progressBarStyle"        android:layout_width="wrap_content"        android:layout_height="wrap_content" />    <TextView        android:layout_gravity="center"        android:id="@+id/textView8"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="80%" /></FrameLayout>

这里写图片描述

阅读全文
0 0
原创粉丝点击