Layouts
【Layouts】
Each layout file must contain exactly one root element, which must be a View or ViewGroup object.
After you've declared your layout in XML, save the file with the .xml extension, in your Android project's res/layout/ directory, so it will properly compile.
When you compile your application, each XML layout file is compiled into a View resource. You should load the layout resource from your application code, in your Activity.onCreate()callback implementation. Do so by calling , passing it the reference to your layout resource in the form of: setContentView()R.layout.layout_file_name. For example, if your XML layout is saved as main_layout.xml, you would load it for your Activity like so:


The at-symbol (@) at the beginning of the string indicates that the XML parser should parse and expand the rest of the ID string and identify it as an ID resource.
The plus-symbol (+) means that this is a new resource name that must be created and added to our resources (in theR.java file).
There are a number of other ID resources that are offered by the Android framework. When referencing an Android resource ID, you do not need the plus-symbol, but must add the android package namespace, like so:


参考:http://android.xsoftlab.net/guide/topics/ui/declaring-layout.html#load
Layouts的更多相关文章
- Advanced Collection Views and Building Custom Layouts
Advanced Collection Views and Building Custom Layouts UICollectionView的结构回顾 首先回顾一下Collection View的构成 ...
- Designing CSS Layouts With Flexbox Is As Easy As Pie
This article is an updated excerpt of the chapter “Restyle, Recode, Reimagine With CSS3″ from our Sm ...
- ExtJS笔记4 容器与布局(Layouts and Containers)
The layout system is one of the most powerful parts of Ext JS. It handles the sizing and positioning ...
- grails的layouts模板页面使用
使用方式1: layouts文件夹下新建文件,名称和Controller名称相同,例如UserController,layouts下面创建user.gsp,此时,user站点下所有的页面都将套用 us ...
- Android用户界面布局(layouts)
Android用户界面布局(layouts) 备注:view理解为视图 一个布局定义了用户界面的可视结构,比如activity的UI或是APP widget的UI,我们可以用下面两种方式来声明布局: ...
- BootStrap入门教程 (一) :手脚架Scaffolding(全局样式(Global Style),格网系统(Grid System),流式格网(Fluid grid System),自定义(Customing),布局(Layouts))
2011年,twitter的“一小撮”工程师为了提高他们内部的分析和管理能力,用业余时间为他们的产品构建了一套易用.优雅.灵活.可扩展的前端工具集--BootStrap.Bootstrap由MARK ...
- 读Qt Demo——Basic Layouts Example
此例程主要展示用代码方式创建控件并用Layout管理类对其进行布局: 例程来自Qt5.2,如过是默认安装,代码位于:C:\Qt\Qt5.2.0\5.2.0\mingw48_32\examples\wi ...
- Using FireMonkey Layouts
FireMonkey has many layout controls to choose from. Come learn the differences and how to use them t ...
- YIi 使用 beginContent() 和 endContent() 设定 Yii 的 layouts
Yii 的 views/layouts 是用来放置 layouts 的目录,在默认的情况下会有 main.php 和 column1.php 和 column2.php. main.php 内容定义了 ...
- ASP.NET MVC- VIEW Creating Page Layouts with View Master Pages Part 4
In this tutorial, you learn how to create a common page layout for multiple pages in your applicatio ...
随机推荐
- PHP按最大宽高等比例缩放图片类 http://www.oschina.net/code/snippet_876708_21113
PHP按最大宽高等比例缩放图片类 http://www.oschina.net/code/snippet_876708_21113 php 等比例缩小图片 http://www.111cn.net/p ...
- springMVC学习(12)-使用拦截器
一.拦截器配置和测试: 1)定义两个拦截器,(要实现HandlerInterceptor接口) HandlerInterceptor1: package com.cy.interceptor; imp ...
- Date类型之继承方法
ECMAScript中的Date类型是在早期Java中的java.util.Date类型基础上构建的.为此,Date类型使用自UTC(国际协调时间)1970年1月1日午夜零时开始经过的毫秒数来保存日期 ...
- HDU 2159 FATE (dp)
FATE Time Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Submissi ...
- selenium page object模式
页面对象模式将测试代码和被测试页面的元素及操作进行分离,以降低页面元素的变化对测试代码的影响.每个被测试的页面都会被定义一个类,类中会定位元素和操作. 如果不使用page object模式,则相同的操 ...
- [UE4]ChildActor组件
ChildActor组件可以让一个actor成为另外actor的组成部分,并在视图中展示出来.
- sencha touch在华为emotion ui 2.0自带浏览器中圆角溢出的bug
在华为emotion ui 2.0自带的浏览器中,给部分组件设置了圆角后会发现背景仍然是方的,内部边框是圆的, 对于这种bug, 只需在对应的设置圆角的css样式中加入 background-clip ...
- mysql 分片
MySQL Fabric(分片) 是一个用于管理 MySQL 服务器群的可扩展框架.该框架实现了两个特性 — 高可用性 (HA ) 以及使用数据分片的横向扩展.这两个特性既可以单独使用,也可以结合使 ...
- 开启saltstack的web界面
saltstack官方有提供一个web界面叫halite,halite是用cherrypy web框架开发的,连接后端的saltstack api,web界面虽然简单点,但功能还算齐全,今天就来开启s ...
- python入门-IF语句
1 格式 cars = ['audi','bmw','subaru','toyata'] for car in cars: if car =='bmw': print(car.upper()) els ...