Android所有可用的资源列表,似乎资源res下的目录是固定的

  • anim
  • drawable
  • layout
  • values
  • xml
  • raw
  • color

此外,是不是能采用子目录的方式呢?这样编辑器是可以通过的,不会报错。但是实际上可不可以你需要参考一下下面的链接,sdk不直接提供读写子目录的方法,而是自动匹配。 http://code.google.com/android/devel/resources-i18n.html#AlternateResources

Android所有可用的资源列表,似乎资源res下的目录是固定的。 http://code.google.com/android/reference/available-resources.html 下面是我们在应用中可以使用的所有资源:

  • Simple Values
  • Drawables
  • Animation
  • Layout
  • Styles and Themes

1. Simple Values 1.1Color Values

Source file format: XML file requiring a declaration, and a root element containing one or more tags. Resource source file location: res/values/colors.xml (file name is arbitrary) Compiled resource datatype: Resource pointer to a Java int. Resource reference name:
  • Java R.color.some_name
  • XML @[package:]color/some_name (where some_name is the name of a specific color)

1.2 Strings and Styled Text

Source file format: XML file requiring a declaration, and a root element containing one or more tags. Resource source file location: res/values/strings.xml (file name is arbitrary) Compiled resource datatype: Resource pointer to a Java CharSequence. Resource reference name:
  • Java R.string.some_name
  • XML @[package:]string/some_name (where some_name is the name of a specific string)

1.3 Dimension Values

Source file format: XML file requiring a declaration, and a root element containing one or more tags. Resource source file location: res/values/dimens.xml (File name is arbitrary; standard practice is to put all dimensions in one file devoted to dimensions.) Compiled resource datatype: Resource pointer to a dimension. Resource reference name:
  • Java R.dimen.some_name
  • XML @[package:]dimen/some_name (where some_name is the name of a specific element)

2.Drawables 2.1 Bitmap files

Source file formats: png (preferred), jpg (acceptable), gif (discouraged). One resource per file. Resource file location: res/drawable/some_file.png or some_file.jpg or some_file.gif. Compiled resource datatype: Resource pointer to a BitmapDrawable . Resource reference name:
  • Java R.drawable.some_file
  • XML @[package:]drawable/some_file

2.2 Color Drawables

Source file format: XML file requiring a declaration, and a root element containing one or more tags. Resource source file location: res/values/colors.xml (File name is arbitrary; standard practice is to put the PaintDrawable items in the file along with the numeric color values .) Compiled resource datatype: Resource pointer to a PaintDrawable . Resource reference name:
  • Java R.drawable.some_name
  • XML @[package:]drawable/some_name (where some_name is the name of a specific resource)

2.3 Nine-Patch Stretchable Image

Source file format: PNG — one resource per file Resource source file location: res/drawable/some_name.9.png (must end in .9.png) Compiled resource datatype: Resource pointer to a NinePatchDrawable . Resource reference name:
  • Java R.drawable.some_file
  • XML @[package:]drawable.some_file

3. Animation 1.1 Tweened Animation

Source file format: XML file, one resource per file, one root tag with no declaration Resource file location: res/anim/some_file.xml Compiled resource datatype: Resource pointer to an Animation . Resource reference name:
  • Java R.anim.some_file
  • XML @[package:]anim/some_file

4.Layout

Source file format: XML file requiring a declaration, and a root element of one of the supported XML layout elements.
Resource file location: res/layout/some_file.xml. Compiled resource datatype: Resource pointer to a View (or subclass) resource. Resource reference name:
  • Java R.drawable.some_file
  • XML @[package:]layout/some_file

4.2 Custom Layout Resources

Source file format: XML file without an declaration, and a root element containing one or more custom element tags. Resource file location: res/values/attrs.xml (file name is arbitrary). Compiled resource datatype: Resource pointer to a View (or subclass) resource. Resource reference name: R.styleable.some_file (Java).

5.Styles and Themes Source file format: XML file requiring a declaration, and a root element containing one or more



如果有一些不是res文件 你又想打包进去的话。你可以把你的资源文件放到assets目录下面。然后通过getClass().getResourceAsStream(name)来获取
package com.readres;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

import java.io.IOException;
import java.io.InputStream;

public class ReadAsset extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// See assets/res/any/layout/styled_text.xml for this
// view layout definition.
setContentView(R.layout.read_asset);

// Programmatically load text from an asset and place it into the
// text view. Note that the text we are loading is ASCII, so we
// need to convert it to UTF-16.
try{
InputStream is=getAssets().open("read_asset.txt");

// We guarantee that the available method returns the total
// size of the asset... of course, this does mean that a single
// asset can't be more than 2 gigs.
int size=is.available();

// Read the entire asset into a local byte buffer.
byte[]buffer=new byte[size];
is.read(buffer);
is.close();

// Convert the buffer into a Java string.
String text=new String(buffer);

// Finally stick the string into the text view.
TextView tv=(TextView)findViewById(R.id.text);
tv.setText(text);
}catch(IOException e){
// Should never happen!
throw new RuntimeException(e);
}

}
}

更多相关文章

  1. Android工程内嵌资源文件的两种方法
  2. “移动开发那点事”——初识3G从android开始,解密Android项目打包
  3. #android learning day 2 #Android Studio项目的目录结构
  4. 清除ANdroid 工程中的无用资源。
  5. Android中资源管理机制详解
  6. android 动画系列 - 目录
  7. Android中读取assets目录下的文件详细介绍

随机推荐

  1. Android(安卓)读取扫码枪的内容,可以读取
  2. Android(安卓)studio升级到3.3后,踩过的各
  3. Android:TextView的垂直滚动效果,和上下
  4. Android框架保证View更新必须在主线程的
  5. android findviewbyId 简化写法
  6. android JNI 多线程 C函数回调
  7. Android(安卓)LiveData 使用
  8. Android(安卓)Studio的Beta, Canary, Dev
  9. Ubuntu12.04 adb无法连接手机
  10. Android创建旋转箭头-不恢复原位-旋转动