- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
外文原文
Beginning Android
Mark L. Murphy write
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 more common approach is to use an XML-based layout file. Dynamic instantiation of widgets is reserved for more complicated scenarios, where the widgets are not known at compile-time (e g., populating a column of radio buttons based on data retrieved off the Internet).
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 (e.g., Eclipse, Ant’s build.xml). Of particular importance to you as a developer is that aapt generates the R.java 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 text in bold, instead of using a property in an XML layout
您可能关注的文档
- Java课程设计--火车售票系统课程设计.doc
- 毕业论文开题报告--混合动力汽车原理及发展前景研究.doc
- 财务管理专业毕业论文--基于博弈论的公司财务舞弊治理分析.doc
- 采矿工程专业毕业论文--煤层注水防尘工艺及其参数选择(济三矿6.0 Mta新井设计).doc
- 道路桥梁工程专业毕业论文--公路设计.doc
- 道路桥梁工程专业外文翻译--高等级公路沥青路面预防性养护.doc
- 道桥专业毕业论文--客运专线双线隧道设计.doc
- 电镀废水处理毕业论文--分步沉淀、混凝法处理电镀废水中Cr6+.doc
- 电气工程及其自动化专业毕业论文--110kV变电站一次部分电气设计.doc
- 电气工程及自动化专业毕业论文--某钢铁企业变电所保护系统及防护系统设计(含外文文献).doc
最近下载
- 2025年新改版教科版五年级上册科学全册精编知识点(新编辑).pdf
- 小学《羽毛球社团》教案(36页) .pdf VIP
- 晶体的点阵结构和晶体的性质.ppt VIP
- 体检中心运用PDCA降低体检中心体检者漏检率品管圈成果汇报书.docx VIP
- 《中国近现代史纲要(2023版)》课后习题答案汇编.docx VIP
- 二氧化碳的高值有效封存利用课件.pptx VIP
- 印花助剂及其应用.pptx VIP
- 海康威视IP SANNAS监控存储解决方案_模版 .pdf VIP
- 第一单元第2课《国色之韵》课件 2025 人教版初中美术八年级上册.ppt
- Q_370705WAD008-2019混合型饲料添加剂氯化铵企业标准.pdf
文档评论(0)