Android所有可用的资源列表

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 on e or more  tags.  Resource source file locationres/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 on e 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 on e 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). On e 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  BitmapDrawableResource 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 on e 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 PaintDrawableResource 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 — on e 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 NinePatchDrawableResource reference name:
  • Java R.drawable.some_file
  • XML @[package:]drawable.some_file
3. Animation 1.1 Tweened Animation
Source file format: XML file, on e resource per file, on e root tag with no declaration  Resource file location: res/anim/ some_file.xml  Compiled resource datatype: Resource pointer to an  AnimationResource 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 on e 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 on e 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 on e or more 



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

imp ort android.app.Activity;
imp ort android.os.Bundle;
imp ort android.widget.TextView;

imp ort java.io.IOException;
imp ort java.io.InputStream;

public class ReadAsset extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void on Create(Bundle savedInstanceState) {
        super.on Create(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);
        }

    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值