`
flyfox1982
  • 浏览: 78431 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

android Layout之FrameLayout

阅读更多
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
1
0
分享到:
评论

相关推荐

    Android Layout多种使用方法源码演示.rar

    Android Layout多种使用方法源码演示,这个例子中演示了如何使用FrameLayout、如何使用RelativeLayout、如何使用RelativeLayout和LinearLayout以及如何使用TableLayout的例子,都挺实用,平时用的比较多,但是比较...

    android自动补全输入框

    输入框,自动补全的输入框,android输入框自动补全输入框 输入框,自动补全的输入框,android输入框自动补全输入框 输入框,自动补全的输入框,android输入框自动补全输入框 输入框,自动补全的输入框,android...

    android之layout(一) FrameLayout、LinearLayout

    NULL 博文链接:https://hanllove001.iteye.com/blog/1185205

    Android布局之帧布局FrameLayout详解

    FrameLayout 在这个布局中,所有的子元素都不能被指定放置的位置,他们统统防御这块区域的左上角, 并且后面的子元素直接覆盖在... android:layout_width=match_parent android:layout_height=match_parent&gt; &lt;Te

    Android布局之FrameLayout帧布局

    作为android六大布局中最为简单的布局之一,该布局直接在屏幕上开辟出了一块空白区域, 当我们往里面添加组件的时候,所有的组件都会放置于这块区域的左上角; 帧布局的大小由子控件中最大的子控件决定,如果都组件都一样...

    Android代码-通过拖拽重排View位置的一个库

    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 XML属性

    Android有Layout:FrameLayout,LinearLayout,TableLayout,RelativeLayout,AbsoluteLayout。 放入Layout中进行排布的View的XML属性: 几种Layout中Item所共有的XML属性:  (1)layout_width  (2)layout_height  ...

    Android控件大全以及各布局空间的使用方式

    android:layout_height="wrap_content" android:text="FrameLayout"&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Frame Layout"&gt; &lt;/...

    Android高薪之路:Android程序员面试宝典 李宁

    《Android高薪之路:Android程序员面试宝典》目录: 第1章 Android入门 1 1 关于Android的非技术问题 1 1 1 为什么看好 Android 1 1 2 以前是否从事过Android的工作 做过哪些工作 1 1 3 你做的最复杂的界面是什么 1 ...

    Android实验指导.doc

    了解布局Layout的应用 多种Layout: AbsoluteLayout FrameLayout GridView LinearLayout ListLayout RadioGroup TableLayout ……… 3. 利用布局安排各种控件,设计良好用户界面 "&lt;LinearLayout " "xmlns:android=...

    ANDROID实验报告组件布局.pdf

    Android 开发 (实验五) 实验题目:... 二、实验内容 组 件 布 局 有 : LinearLayout 、 TableLayout 、 FrameLayout 、 RelativeLayout 三、实验步骤 1、用表格布局完成登录界面 &lt;TableLayout xmlns:android=...

    Android Layout 示例

    包括LinearLayout、RelativeLayout、TableLayout、FrameLayout、AbsoluteLayout等常见layout的示例程序

    基于AnDroid FrameLayout的使用详解

    今天在学习实现墨迹天气那样的拖动效果时,看到用...FrameLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”fill_parent” an

    Android自定义SeekBar滑动显示数字

    当滑动时:数值显示,滑动停止时显示数字,使用FrameLayout结合SeekBar。 首先我们看看。 Layout: &lt;?xml version=1.0 encoding=utf-8?&gt; &lt;merge xmlns:android=http://schemas.android.com/apk/res/android ...

    Android中UI布局Layout

    线性布局LinearLayout 框架布局FrameLayOut RelativeLayout相对布局 绝对布局AbsoluteLayout TableLayout表格布局

    Android-ForegroundViews-类似于FrameLayout的支持的前景自定义View

    ForegroundViews - 类似于 FrameLayout 的支持的前景自定义 View

    谈谈Android里的Context的使用

    import android.widget.FrameLayout; /** * @author carlshen. * 自定义的MainView. */ public class MainView extends FrameLayout implements View.OnClickListener{ private Context mContext; ...

    Android实验指导(1).doc

    了解布局Layout的应用 多种Layout: AbsoluteLayout FrameLayout GridView LinearLayout ListLayout RadioGroup TableLayout ……… 3. 利用布局安排各种控件,设计良好用户界面 "&lt;LinearLayout " "xmlns:android=...

    Android代码-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@...

    Android自适应屏幕大小和layout布局

    一:不同的layoutAndroid手机屏幕大小不一,有480x320,640x360,800x480.怎样才能让App自动适应不同的屏幕呢?其实很简单,只需要在res目录下创建不同的layout文件夹,比如layout-640x360,layout-800x480,所有的layout...

Global site tag (gtag.js) - Google Analytics