`
亚当爱上java
  • 浏览: 698155 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Android Layout之一:FrameLayout

阅读更多
Android Layout有五大布局对象,分别是FrameLayout(帧布局),LinearLayout (线性布局),AbsoluteLayout(绝对布局),RelativeLayout(相对布局),TableLayout(表格布局).


FrameLayout:该布局container可以用来占有屏幕的某块区域来显示单一的对象,可以包含有多个widgets或者是container,但是所有被包含的widgets或者是container必须被固定到屏幕的左上角,并且一层覆盖一层,不能通过为一个widgets或者是container指定一个位置。Container所包含的widgets或者是container的队列是采用的堆栈的结构,最后加进来的widgets或者是container显示在最上面。所以后一个widgets或者是container将会直接覆盖在前一个widgets或者是container之上,把它们部份或全部挡住(除非后一个widgets或者是container是透明的,必须得到FrameLayout Container的允许)。

其中Main.xml 代码如下:

<?xml version="1.0" encoding="utf-8"?>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:orientation="vertical"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    >

<TextView 

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:text="@string/hello"

    />

    <TextView

        android:textColor = "#0000FF"

        android:layout_width = "wrap_content"

        android:layout_height = "wrap_content"

        android:text = "@string/hello2"

       />

</FrameLayout>

Strings.xml代码如下:

<?xml version="1.0" encoding="utf-8"?>

<resources>

    <string name="hello">Hello World, LayoutTestActivity!</string>

    <string name="app_name">LayoutTest</string>

    <string name="hello2">Hello World, I can not be LOST!</string>

</resources>

如下图,其中TextView Hello2是最后FrameLayout最后加入的,所以该TextView应该是覆盖整个屏幕的,TextView hello1被其覆盖:



  • 大小: 7.3 KB
分享到:
评论

相关推荐

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

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

    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实验报告组件布局.pdf

    Android 开发 (实验五) 实验题目:Android 组件布局试验 指导老师: 班 级:计算机科学与技术系班 姓 名: 一、实验目的 1、掌握 Android 组件布局的使用方法 2、学会组件布局的重要属性与应用 3、能够根据需求,...

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

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

    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 布局文件Layout XML属性

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

    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实验指导.doc

    Android实验指导 实验一:系统安装与HelloWorld 【目的】 安装智能手机开发相关软件平台。 【要求】 1. 完成智能手机开发平台安装、以及相关配置 2. 并实现Hello World 3. 了解项目的基本文件目录结构 【原理】 ...

    Android实验指导(1).doc

    Android实验指导 实验一:系统安装与HelloWorld 【目的】 安装智能手机开发相关软件平台。 【要求】 1. 完成智能手机开发平台安装、以及相关配置 2. 并实现Hello World 3. 了解项目的基本文件目录结构 【原理】 ...

    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自动补全输入框

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

    谈谈Android里的Context的使用

    这里大致可以分为两种:一是传递Context参数,二是调用全局的Context. 其实我们应用启动的时候会启动Application这个类,这个类是在AndroidManifest.xml文件里其实是默认的 android:icon="@drawable/ic_...

    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 FrameLayout的使用详解

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

    自己平时做的android相关的总结

    android-apt-compiler: [t1] res\layout\LinearLayout.xml: Invalid file name: must contain only [a-z0-9_.] Buttons in button bars should be borderless android 支持的距离单位 使用adb shell命令进入手机后...

    高仿微信界面

    android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"&gt; &lt;include layout="@layout/layout_main_top" /&gt; &lt;android.support.v4.view.ViewPager ...

    解决android 软键盘在全屏下设置adjustResize无效的问题

    全屏模式下,即使将activity的windowSoftInputMode的属性设置为:...在你的Activity的oncreate()方法里调用AndroidBug5497Workaround.assistActivity(this);即可。注意:在setContentView(R.layout.xxx)之后调用。

    Android layout_weight使用方法及实例

    &lt;LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”match_parent” android:orientation=”horizontal”&gt; &lt;...

    Android程序技术:常见布局的创建.pptx

    在Android程序中界面是通过布局文件设定的,在每个应用程序创建时会默认包含一个主界面布局,该布局位于res/layout目录中。 实际开发中每个应用程序都包含多个界面,而程序默认提供的一个主界面布局无法满足需求,...

Global site tag (gtag.js) - Google Analytics