Created
June 28, 2011 01:48
-
-
Save itoz/1050317 to your computer and use it in GitHub Desktop.
Android ライブ壁紙 Drawable 描画用 あれこれサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Android ライブ壁紙 Drawable 描画用 あれこれサンプル | |
// | |
/**================================== | |
* R.java から Drawable取得 | |
*/ | |
// 取得 | |
private Drawable _image; | |
_image = r.getDrawable(R.drawable.image0); | |
/**================================== | |
*描画 | |
*/ | |
int x =0; | |
int y =0; | |
int w = _image.getIntrinsicWidth();//Drawableの幅取得 | |
int h= _image.getIntrinsicHeight();//Drawableの高さ取得 | |
_image.setBounds(x, y, x + w, y + h);//★必ず呼ぶ | |
_image.setAlpha(255);//アルファ0〜255 | |
_image.draw(c); | |
/**================================== | |
*カラーフィルター 例 | |
*/ | |
//カラーフィルターをかける | |
ColorFilter cf = new PorterDuffColorFilter(Color.BLUE, PorterDuff.Mode.MULTIPLY); | |
_image.setColorFilter(cf); | |
//もしくは | |
_image.setColorFilter(Color.BLUE, PorterDuff.Mode.MULTIPLY); | |
/**================================== | |
* R.java から動的にDrawableを取得 | |
*/ | |
_image = _res.getDrawable(getResources().getIdentifier("ファイル名", "drawable", getPackageName())); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment