FrameLayout在屏幕上开辟了一块区域,在这块区域中可以添加多个子控件,但是所有的子控件都会被对齐到屏幕的左上角。FrameLayout的大小由其所添加的所有子控件中尺寸最大的那个子控件来控制。如果子控件的大小都一样,同一时刻只能看到最上面的子控件,其他的则被其遮挡(在进行选项卡设计时会用到帧布局)。在FrameLayout中,子控件是通过栈来绘制的,所以后添加的子控件会被绘制在上层。
示例代码如下:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text = "short text"/>
<TextView android:id="@+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor = "#0000FF"
android:textSize="40px"
android:text = "This is a long text ,long text"/>
</FrameLayout>
结果显示如下:
FrameLayout继承ViewGroup类,除了继承父类的属性和方法外,FrameLayout类中还包含了自己特有属性和方法:
android:foreground (setForeground(Drawable))设置绘制在所有子控件之上的内容
android:foregroundGravity(setForegroundGravity(int))设置绘制在所有子控件之上内容的gravity属性
- 大小: 9.1 KB
分享到:
相关推荐
Android Layout多种使用方法源码演示,这个例子中演示了如何使用FrameLayout、如何使用RelativeLayout、如何使用RelativeLayout和LinearLayout以及如何使用TableLayout的例子,都挺实用,平时用的比较多,但是比较...
输入框,自动补全的输入框,android输入框自动补全输入框 输入框,自动补全的输入框,android输入框自动补全输入框 输入框,自动补全的输入框,android输入框自动补全输入框 输入框,自动补全的输入框,android...
NULL 博文链接:https://hanllove001.iteye.com/blog/1185205
FrameLayout 在这个布局中,所有的子元素都不能被指定放置的位置,他们统统防御这块区域的左上角, 并且后面的子元素直接覆盖在... android:layout_width=match_parent android:layout_height=match_parent> <Te
作为android六大布局中最为简单的布局之一,该布局直接在屏幕上开辟出了一块空白区域, 当我们往里面添加组件的时候,所有的组件都会放置于这块区域的左上角; 帧布局的大小由子控件中最大的子控件决定,如果都组件都一样...
Android Rearrangeable Layout An android layout to re-arrange child views via dragging Screencast Demo Layout Usage All the child views are draggable once the layout is added to an activity (activity...
Android有Layout:FrameLayout,LinearLayout,TableLayout,RelativeLayout,AbsoluteLayout。 放入Layout中进行排布的View的XML属性: 几种Layout中Item所共有的XML属性: (1)layout_width (2)layout_height ...
android:layout_height="wrap_content" android:text="FrameLayout"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Frame Layout"> </...
《Android高薪之路:Android程序员面试宝典》目录: 第1章 Android入门 1 1 关于Android的非技术问题 1 1 1 为什么看好 Android 1 1 2 以前是否从事过Android的工作 做过哪些工作 1 1 3 你做的最复杂的界面是什么 1 ...
了解布局Layout的应用 多种Layout: AbsoluteLayout FrameLayout GridView LinearLayout ListLayout RadioGroup TableLayout ……… 3. 利用布局安排各种控件,设计良好用户界面 "<LinearLayout " "xmlns:android=...
Android 开发 (实验五) 实验题目:... 二、实验内容 组 件 布 局 有 : LinearLayout 、 TableLayout 、 FrameLayout 、 RelativeLayout 三、实验步骤 1、用表格布局完成登录界面 <TableLayout xmlns:android=...
包括LinearLayout、RelativeLayout、TableLayout、FrameLayout、AbsoluteLayout等常见layout的示例程序
今天在学习实现墨迹天气那样的拖动效果时,看到用...FrameLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”fill_parent” an
当滑动时:数值显示,滑动停止时显示数字,使用FrameLayout结合SeekBar。 首先我们看看。 Layout: <?xml version=1.0 encoding=utf-8?> <merge xmlns:android=http://schemas.android.com/apk/res/android ...
线性布局LinearLayout 框架布局FrameLayOut RelativeLayout相对布局 绝对布局AbsoluteLayout TableLayout表格布局
ForegroundViews - 类似于 FrameLayout 的支持的前景自定义 View
import android.widget.FrameLayout; /** * @author carlshen. * 自定义的MainView. */ public class MainView extends FrameLayout implements View.OnClickListener{ private Context mContext; ...
了解布局Layout的应用 多种Layout: AbsoluteLayout FrameLayout GridView LinearLayout ListLayout RadioGroup TableLayout ……… 3. 利用布局安排各种控件,设计良好用户界面 "<LinearLayout " "xmlns:android=...
A simple aspect ratio layout for Android. ScreenShot Usage Gradle compile 'com.takwolf.android:aspectratio:0.0.3' Layout PS: AspectRatioLayout is extends FrameLayout. Author TakWolf takwolf@...
一:不同的layoutAndroid手机屏幕大小不一,有480x320,640x360,800x480.怎样才能让App自动适应不同的屏幕呢?其实很简单,只需要在res目录下创建不同的layout文件夹,比如layout-640x360,layout-800x480,所有的layout...