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 setContentView(), passing it the reference to your layout resource in the form of: 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

时间: 2024-08-14 21:18:08

Layouts的相关文章

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 Smashing Book #3, written by Lea Verou and David Storey. - Ed. Flexible box layout (or flexbox) is a new box model optimized for UI layout. As one of th

Yii2系列教程二:MVC,Forms和Layouts

上一篇文章我们简单地实现了Yii2框架安装和Hello World,而在这一篇文章当中,我们会带着好奇之心去探索一下在Yii2中的几个重要的元素组成:MVC,Forms和Layouts. 本文的目标是创建一个小小的表单应用,就是实现一个简单的类似发微博的功能,但是我还不想牵扯到数据库那一块,因为其实数据库和表在Yii2框架之中其实还是有很多东西可以讲的,打算在下一篇的文章中会详细讲到. MVC 模型(Model)对于我个人的简单理解就是一个概念集合,在这个集合里面包含该概念集合的多种数据,比如一

YIi 使用 beginContent() 和 endContent() 设定 Yii 的 layouts

Yii 的 views/layouts 是用来放置 layouts 的目录,在默认的情况下会有 main.php 和 column1.php 和 column2.php. main.php 内容定义了,<head> 以及 page header 和 footer 等. column1.php 和 column2.php 是使用 main.php 的网页布局,但修改内容的部份. 例如,我们有个 layout 叫做 mylayout.php: <?php $this->beginCon

[CSS] Build Responsive CSS Layouts with Tachyons

Building responsive css layouts is critical in any modern website. Tachyons makes this easy by designing for mobile first then enabling you to switch directions and positions of elements when the site scales up to desktop sizes. This lesson walks you

LEXUS OPENCART 自适应主题模板 ABC-0017 FLEXIBLE LAYOUTS –

LEXUS OPENCART 自适应主题模板 ABC-0017 FLEXIBLE LAYOUTS – MODULES 兼容浏览器 IE8, IE9, IE10, IE11, Firefox, Safari, Opera, Chrome OpenCart版本 OpenCart 2.0.x, OpenCart 1.5.6.x, OpenCart 1.5.5.x, OpenCart 1.5.5, OpenCart 1.5.4 包含文件 Layered PSD, PHP Files, CSS Files

关于Layouts的分类

ViewGroup ---------------------------------LinearLayout.Relative Layout. AdapterView ----------------------------ListView.GridView | |(Adapter) | ----------------------------ArrayAdapter.SimpleAdapter.SimpleCursorAdapter.BaseAdapter 关于Layouts的分类,布布扣,

QML官方教程——Qt Quick Layouts Overview

附网址:http://qt-project.org/doc/qt-5/qtquicklayouts-overview.html Qt Quick Layouts Overview -- Qt Quick Layouts概述 Qt Quick Layouts是用来对用户界面中的组件进行布局的一套组件.由于Qt Quick Layouts会根据实际情况动态调整其内部组件的尺寸,因此它非常适合被用在尺寸可变的用户界面中. Getting Started 在.qml文件里使用如下声明将其引入到你的应用程

Using FireMonkey Layouts

FireMonkey has many layout controls to choose from. Come learn the differences and how to use them to create dynamic, multi-platform user interfaces. FireMonkey Layouts with Delphi FireMonkey Layouts with C++Builder Understanding and using FireMonkey

Consider adding android:paddingStart=“25dp” to better support right-to-left layouts Error

更新了ADT后在android上设置editText上设置padding属性时遇到了这个问题: Multiple annotations found at this line: - Consider adding android:paddingStart="25dp" to better support right-to-left layouts - When you define paddingLeft you should probably also define paddingR