リソースファイルの設置場所と利用方法

res/xmlフォルダの1MB以上のxmlファイルは読み込めない
画像を解像度ごとに振り分ける方法(drawable、layout、valuesなどの修飾句)
国際化する方法(drawable、layout、valuesなどの修飾句)
res/drawableの画像を変更しても、変更が反映されない場合
assetsフォルダには1MB以上の非圧縮ファイルを設置できない

フォルダ 説明 利用例
/res/values/ 色(Color) int color=getResources().getColor(R.color.color_red);
寸法 float dim=getResources().getDimension(R.dimen.one_pixel);
色(ColorDrawable) Drawable drawable = Resources.getDrawable(R.drawable.color_red);
文字列 CharSequence str=getString(R.string.string_text);
テーマ/スタイル setTheme(R.style.Theme_CommonTheme);
/res/drawable/ ビットマップ(画像)
Bitmap(*.bmp)
JPEG(*.jpg)
PNG(*.png)
GIF(*.gif)
button.setBackgroundResource(R.drawable.hoge);
ナインパッチ
Nine-Patch(*.9.png)
button.setBackgroundResource(R.drawable.hoge);
/res/layout/ レイアウト setContentView(R.layout.hoge);
/res/anim/ アニメーション Animation animation=AnimationUtils.loadAnimation(this,R.anim.spin);
/res/raw/ バイナリ MediaPlayer player=MediaPlayer.create(this,R.raw.hoge);
InputStream in=getResources().openRawResource(R.raw.hoge);
/res/xml/ XML hoge.xml
XmlResourceParser parser=getResources().getXML(R.xml.hoge_xml);

[参考記事] ナインパッチとは(9-Patch)

関連記事

スポンサーリンク

Twitterウィジェットのカスタマイズ(ウィジェット部分のHTML・CSS)

ホームページ製作・web系アプリ系の製作案件募集中です。

上に戻る