下载此文档

外文文献-Beginning Android Android起航.doc


文档分类:IT计算机 | 页数:约36页 举报非法文档有奖
1/36
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/36 下载此文档
文档列表 文档介绍
毕业设计
外文文献原文及译文
Beginning Android
Android起航
计算机系
学生姓名: 学号:
网络工程
系别:
专业:
指导教师:
2015年 5 月
Beginning Android
Using XML-Based Layouts
While it is technically possible to create and attach widgets to our activity purely through Java code, the way we did in Chapter 4, the mon approach is to use an XML-based layout file. Dynamic instantiation of widgets is reserved for plicated scenarios, where the widgets are not known pile-time (e g., populating a column of radio buttons based on data retrieved off the ).
With that in mind, it’s time to break out the XML and learn how to lay out Android activities that way.
What Is an XML-Based Layout?
As the name suggests, an XML-based layout is a specification of widgets’ relationships to each other—and to their containers (more on this in Chapter 7)—encoded in XML format. Specifically, Android considers XML-based layouts to be resources, and as such layout files are stored in the res/layout directory inside your Android project.
Each XML file contains a tree of elements specifying a layout of widgets and their containers that make up one view hierarchy. The attributes of the XML elements are properties, describing how a widget should look or how a container should behave. For example, if a Button element has an attribute value of android:textStyle = "bold", that means that the text appearing on the face of the button should be rendered in a boldface font style.
Android’s SDK ships with a tool (aapt) which uses the layouts. This tool should be automatically invoked by your Android tool chain (., Eclipse, Ant’s ). Of particular importance to you as a developer is that aapt generates the source file within your project, allowing you to access layouts and widgets within those layouts directly from your Java code.
Why Use XML-Based Layouts?
Most everything you do using XML layout files can be achieved through Java code. For example, you could use setTypeface() to have a button render its tex

外文文献-Beginning Android Android起航 来自淘豆网m.daumloan.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数36
  • 收藏数0 收藏
  • 顶次数0
  • 上传人mkjafow
  • 文件大小595 KB
  • 时间2017-12-05