2012-08-28 62 views
6

アイコン上にこの青い光の効果を得るには?それを行う簡単な方法はありますか?私は実際にこの効果のためにPhotoshopを使いたくありません。Android - アイコンをタッチする方法を教えてください。

本当にありがとうございます。

+0

:私のアドバイス、コメントで言ったように、そして、それを使用してStateListDrawableを作成し、あなたの活動のbegginingで一度だけ、それを生成スレッドhttp://stackoverflow.com/questions/6501716/android-how-to-create-a-statelistdrawable-programmatically にアクセスするか、http://developer.android.com/guide/topics/resources/にアクセスしてください。 drawable-resource.html –

答えて

21

あなたがプログラム的な輝きを生成したい場合は、ここではあなたがすることができる方法です。あなたは青いeffect.Pleaseを定義しますするstatelistdrawablesの使用をしなければならない

// An added margin to the initial image 
    int margin = 24; 
    int halfMargin = margin/2; 

    // the glow radius 
    int glowRadius = 16; 

    // the glow color 
    int glowColor = Color.rgb(0, 192, 255); 

    // The original image to use 
    Bitmap src = BitmapFactory.decodeResource(getResources(), 
      R.drawable.ic_launcher); 

    // extract the alpha from the source image 
    Bitmap alpha = src.extractAlpha(); 

    // The output bitmap (with the icon + glow) 
    Bitmap bmp = Bitmap.createBitmap(src.getWidth() + margin, 
      src.getHeight() + margin, Bitmap.Config.ARGB_8888); 

    // The canvas to paint on the image 
    Canvas canvas = new Canvas(bmp); 

    Paint paint = new Paint(); 
    paint.setColor(glowColor); 

    // outer glow 
    paint.setMaskFilter(new BlurMaskFilter(glowRadius, Blur.OUTER)); 
    canvas.drawBitmap(alpha, halfMargin, halfMargin, paint); 

    // original icon 
    canvas.drawBitmap(src, halfMargin, halfMargin, null); 

    ((ImageView) findViewById(R.id.bmpImg)).setImageBitmap(bmp); 
+0

コメントを使用して説明した方法が本当に気に入りました。ありがとう。 – Varundroid

関連する問題