2012-08-28 3 views
6

아이콘 위에 파란 광선 효과를 얻으려면 어떻게해야하나요? 그것을하는 빠른 방법이 있습니까? 나는이 효과를 위해 포토샵을 사용하고 싶지 않습니다.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