Android所有可用的资源列表,似乎资源res下的目录是固定的
de.google.com/android/devel/resources-i18n.html#AlternateResources
Android所有可用的资源列表,似乎资源res下的目录是固定的。 http://co de.google.com/android/reference/available-resources.html 下面是我们在应用中可以使用的所有资源:
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);
}
}
}
- anim
- drawable
- layout
- values
- xml
- raw
- color
Android所有可用的资源列表,似乎资源res下的目录是固定的。 http://co
- Simple Values
- Drawables
- Animation
- Layout
- Styles and Themes
Source file format: XML file requiring a declaration, and a root element containing on1.2 Strings and Styled Texte 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)
Source file format: XML file requiring a declaration, and a root element containing on1.3 Dimension Valuese 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)
Source file format: XML file requiring a declaration, and a root element containing on2.Drawables 2.1 Bitmap filese or more tags. Resource source file location: res/values/dimens.xml (File name is arbitrary; standard practice is to put all dimensions in on e 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)
Source file formats: png (preferred), jpg (acceptable), gif (discouraged). On2.2 Color Drawablese 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
Source file format: XML file requiring a declaration, and a root element containing on2.3 Nine-Patch Stretchable Imagee 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)
Source file format: PNG — on3. Animation 1.1 Tweened Animatione 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
Source file format: XML file, on4.Layoute 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 Animation. Resource reference name:
- Java R.anim.some_file
- XML @[package:]anim/some_file
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:4.2 Custom Layout Resources
- Java R.drawable.some_file
- XML @[package:]layout/some_file
Source file format: XML file without an declaration, and a root element containing on5.Styles and Themes Source file format: XML file requiring a 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).
如果有一些不是res文件 你又想打包进去的话。 你可以把你的资源文件放到assets目录下面。然后通过getClass().getResourceAsStream(name)来获取
package com.readres;
imp
imp
imp
imp
imp
public class ReadAsset extends Activity {
/** Called when the activity is first created. */
@Override
public void on
super.on
// 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);
}
}
}