xamarin android pdf,Xamarin 中的Android资源及使用.pdf
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的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: matlab判断电话播键音,MATLAB
- 下一篇: HFSS - GSM 900 和 DCS