- 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
您可能关注的文档
- 《MATLAB数值计算》(美)Cleve B.Moler 第三章插值第1节插值多项式 毕业设计(论文)英文文献翻译.doc
- 《基于激光散斑法的金属表面状态分析》文献翻译、读书报告、文献综述.doc
- 51单片机 毕业论文外文翻译.doc
- A2.1配电系统毕业论文外文翻译.doc
- A5191HRT型HART调制解调器 毕业论文外文翻译.doc
- ActionScript 3.0概述 毕业论文外文翻译.doc
- AT89C51单片机 毕业论文外文翻译.doc
- C# 简介 毕业论文外文翻译.doc
- CK滚筒碾粉机 毕业论文外文翻译.docx
- CMOS4046集成电路研究锁相环(PLL)的工作原理 毕业论文外文翻译.docx
最近下载
- 人教版高中数学精讲精练必修二101 随机事件与概率(精练)(原卷版).pdf VIP
- SYT6391-2014 SEG D Rev3.0地震数据记录格式.pdf VIP
- 2025至2030中国硬盘行业发展分析及发展趋势分析与未来投资战略咨询研究报告.docx
- 石楼南煤层气勘查实施方案.docx VIP
- 人教版高中数学精讲精练必修一1.2 集合间的关系(精讲)(解析版).pdf VIP
- IPV4和IPV6地址.ppt VIP
- 秀出你风采——ppt创意动画知到智慧树期末考试答案题库2024年秋黑龙江幼儿师范高等专科学校.docx VIP
- 我国辽中南工业区等.ppt VIP
- 重大事故隐患安全管理制度.docx VIP
- 电子海图课件--TOKYO-KEIKI8600.ppt VIP
原创力文档


文档评论(0)