Providing Resources

阅读:http://developer.android.com/guide/topics/resources/providing-resources.html

安卓开发的文件结构及其含义:

DirectoryResource Type
animator/XML files that define property animations.
anim/XML files that define tween animations. (Property animations can also be saved in this directory, but the animator/ directory is preferred for property animations to distinguish between the two types.)
color/XML files that define a state list of colors. See Color State List Resource
drawable/

Bitmap files (.png, .9.png, .jpg, .gif) or XML files that are compiled into the following drawable resource subtypes:

  • Bitmap files
  • Nine-Patches (re-sizable bitmaps)
  • State lists
  • Shapes
  • Animation drawables
  • Other drawables

See Drawable Resources.

layout/XML files that define a user interface layout. See Layout Resource.
menu/XML files that define application menus, such as an Options Menu, Context Menu, or Sub Menu. See Menu Resource.
raw/

Arbitrary files to save in their raw form. To open these resources with a raw InputStream, call Resources.openRawResource() with the resource ID, which is R.raw.filename.

However, if you need access to original file names and file hierarchy, you might consider saving some resources in the assets/ directory (instead of res/raw/). Files in assets/ are not given a resource ID, so you can read them only using AssetManager.

values/

XML files that contain simple values, such as strings, integers, and colors.

Whereas XML resource files in other res/ subdirectories define a single resource based on the XML filename, files in the values/ directory describe multiple resources. For a file in this directory, each child of the <resources> element defines a single resource. For example, a <string> element creates an R.string resource and a <color> element creates an R.color resource.

Because each resource is defined with its own XML element, you can name the file whatever you want and place different resource types in one file. However, for clarity, you might want to place unique resource types in different files. For example, here are some filename conventions for resources you can create in this directory:

See String Resources, Style Resource, and More Resource Types.

xml/Arbitrary XML files that can be read at runtime by calling Resources.getXML(). Various XML configuration files must be saved here, such as a searchable configuration.

Caution: Never save resource files directly inside the res/ directory—it will cause a compiler error.

 


 

 

接下来的API指导告诉你该怎么根据机器的变化自动进行适应。一般是:1、先建立不同条件下的资源以及RES下的文件;2、然后把各种资源命名为一模一样;

对于条件一,怎么定义文件夹的名字,在指导页面的表格2有说明。


 

 

接下来的指导说明了如何进行详细的操作,有需要可自行参考。

转载于:https://www.cnblogs.com/yutoulck/p/3386875.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值