网站大量收购独家精品文档,联系QQ:2885784924

Xamarin 中的Android资源及使用.pdf

  1. 1、本文档共45页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Xamarin 中的Android资源及使用

Xamarin 中的Android 资源及使用 本文介绍Xamarin Android 中的Android 资源概念,以及如何使用资源。 讨论如何使用资源实现应用程序 地化,多种设备支持如各种屏幕大小 和密度。 This article introduces the concept of Android resources in Xamarin.Android and will document how to use them. It covers how to use resources in your Android application to support application localization, and multiple devices including varying screen sizes and densities. 概述Overview 很少有Android 应用程序只包含源码。通常还有很多组成应用程序的文件:视频、图像、音 频文件等等。总体上说,非源码文件都是资源,在生成过程和打包APK 的时候与源码一起 编辑,并同时安装到设备: An Android application is seldom just source code. There are often many other files that make up an application: video, images, and audio files just to name a few. Collectively, these non-source code files are referred to as resources and are compiled (along with the source code) during the build process and packaged as an APK for distribution and installation onto devices: 资源为Android 应用程序提供各种优势: 代码隔离 将代码与图像、字符、菜单、动画、颜色等隔离开。比如可以方便的 地化。 多设备部署 无需修改代码就可以简单的实现不同设备的配置支持。 编译时检查 资源是静态的,可编译到应用程序中。这样就可以在编译的时候检查资源,修 正错误,否则在运行时很难定位和修改错误。 当新创建一个Xamarin Android 项目,会创建一个叫做Resources 的目录,同时还有很多子 目录: Resources offer several advantages to an Android application: Code-Separation - Separates source code from images, strings, menus, animations, colors, etc. As such resources can help considerably when localizing. Target multiple devices –Provides simpler support of different device configurations without code changes. Compile-time Checking - Resources are static and compiled into the application. This allows the usage of the resources to be checked at compile time, when it will be easy to catch and correct the mistakes, as opposed to run-time when it is more difficult to locate and costly to correct. When a new Xamarin.Android proj ect is started, a special directory called Resources is created, along with some subdirectories: 上图所示,应用程序资源按类型组织到各个子目录中:图像放在drawable 目录;控件放在 layout 目录等等。 在Xamarin Android 应用程序中有两种方式访问这些资源:使用代码或声明式XML 。 这些资源叫做默认资源可用于所有设备,除非指定了设备匹配

文档评论(0)

dajuhyy + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档