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 。

这些资源叫做默认资源可用于所有设备,除非指定了设备匹配

xamarin android pdf,Xamarin 中的Android资源及使用.pdf相关推荐

  1. 使用Xamarin在Visual Studio中开发Android应用

    原文:使用Xamarin在Visual Studio中开发Android应用 本文使用的环境是Windows 8 Visual Studio 2012.2 1.下载Xamarin http://xam ...

  2. 如何在linux上开发安卓软件,使用Xamarin在Visual Studio中开发Android应用

    本文使用的环境是Windows 8 Visual Studio 2012.2 1.下载Xamarin 2.安装Xamarin 下载后运行EXE文件 之后经过一些必要的下一步 想要开发Android,A ...

  3. [Android]Android布局文件中的android:id=@*属性使用方法汇总以及介绍

    由于项目需要进行Android开发,因此一边开发,一边查阅资料,一边总结了Android布局文件中android:id="@*"属性的使用方法汇总以及介绍.id资源的引用 andr ...

  4. Android开发-WebView中实现Android调用JS JS调用Android 【三】

    老早之前就想总结下Webview相关的知识点了,因为互联网大潮中,很多APP都会使用到Webview,像那些不计其数的电商APP,无一例外的使用Webview:或者一些非电商APP中的像广告页面,注册 ...

  5. nodejs+html转换pdf,Nodejs中使用phantom将html转为pdf或图片格式的方法

    最近在项目中遇到需要把html页面转换为pdf的需求,并且转换成的pdf文件要保留原有html的样式和图片.也就是说,html页面的图片.表格.样式等都需要完整的保存下来. 最初找到三种方法来实现这个 ...

  6. nodejs+html转换pdf,Nodejs中使用phantom将html转为pdf或图片格式的方法.pdf

    Nodejs中中使使用用phantom将将html转转为为pdf或或图图片片格格式式的的方方法法 最近在项目中遇到需要把html页面转换为pdf 的需求,并且转换 的pdf文件要保留原有html的样式 ...

  7. 计算机无法快速预览pdf,电脑中无法使用火狐浏览器预览PDF文档怎么解决

    ‍ 在火狐浏览器中具有在网页中支持打开PDF文档的功能.有用户在使用Firefox打开PDF文档时却被提示需要保存文件,而不能直接在页面中预览.如果遇到上述的情况,我们应该如何操作才能在火狐浏览器中直 ...

  8. Android测量图像中物体大小,android – 加载图像后测量ImageView

    我试图找到一种方法来测量ImageView后使用Glide或Picasso(或其他任何东西)加载图像.基本上,我试图在某些位置在图像顶部布局其他视图,但需要最终的ImageViews尺寸才能准确地完成 ...

  9. android 打印机列表中,在android中打印只搜索打印机

    我已经做了一个android应用程序,我试图打印一个示例文本文件,我想使用wifi连接打印机,我试过这个链接Wifi printing in android但它只是去搜索wifi打印机和什么都不做,我 ...

  10. 美图 android sdk,ADT中使用Android SDK Manager安装X86的System Image | 在路上

    之前折腾: 的过程中,需要去用Android SDK Manager安装X86的System Image.下面记录过程: 1.去运行Android SDK Manager: 2.打开后,很快就找到了, ...

最新文章

  1. 逼学生作弊的AI阅卷老师
  2. PHP sprintf() 函数
  3. 一次性配置VS2015属性的方法,新工程无需重新配置
  4. python_购物车
  5. linux服务器登录时慢出现卡顿
  6. [Java基础]线程安全的类
  7. 一文教你轻松搞定ANR异常捕获与分析方法
  8. IP地址、子网掩码、网关、默认网关、DNS的理解
  9. 详解linux io flush
  10. Ubuntu 安装 cuda 时卡在登录界面(login loop)的解决方案之一
  11. ajax前端取消用户发送重复请求
  12. 本地修改服务器上的内容,本地修改指向服务器
  13. 解决Ubuntu “E: 软件包 vim 还没有可供安装的候选者“问题
  14. 【To Understand !!! DP or 递归】LeetCode 87. Scramble String
  15. 「leetcode」763. 划分字母区间:【记录最远位置与双指针】详解
  16. seay svn漏洞利用工具_史上最强的iPhone越狱工具开源了,永久有效,从4s到X都支持:利用了iOS大漏洞...
  17. 计算机制图作品答辩,工程制图(第一章)答辩.ppt
  18. 地理坐标(经纬度坐标)和屏幕坐标(xy坐标)间的转换
  19. Lab multicast msdp
  20. CAD梦想画图中“插入图片”

热门文章

  1. 前端中LED字体的实现
  2. 第十一届蓝桥杯校内赛/校内选拔赛(2020蓝桥杯校选3-java)部分解题思路
  3. web前端行业调研报告_web前端开发述职报告
  4. 管理信息系统开发项目管理(VIVID)
  5. HTML+CSS小米注册登录界面
  6. [学习]啦啦外卖定位修复,商家经纬度保存修复
  7. centos 计算器_在Linux命令行中使用计算器的5个命令
  8. 手机如何利用IP地址定位城市
  9. AllWinner T113交叉工具链篇
  10. 关于TP5-微信H5支付