2012-08-28 23 views
6

एक आइकन पर इस नीली चमक प्रभाव कैसे प्राप्त करें? क्या ऐसा करने का कोई त्वरित तरीका है? मैं वास्तव में इस प्रभाव के लिए फ़ोटोशॉप का उपयोग नहीं करना चाहता।एंड्रॉइड - स्पर्श पर आइकन चमक कैसे बनाएं?

किसी भी मदद की वास्तव में सराहना की जाएगी।

+0

आप जिसमें आप नीले effect.Please परिभाषित करेगा statelistdrawables का उपयोग करने के लिए है थ्रेड http://stackoverflow.com/questions/6501716/android-how-to-create-a-statelistdrawable-programmatically पर जाएं या आप http://developer.android.com/guide/topics/resources/ पर जा सकते हैं drawable-resource.html –

उत्तर

21

आप प्रोग्राम के चमक उत्पन्न करने के लिए चाहते हैं, तो यहाँ आप कैसे कर सकते हैं। मेरी सलाह है, यह अपनी गतिविधि की शुरुआत में सिर्फ एक बार उत्पन्न है, तो, इसे का उपयोग एक StateListDrawable बनाने के रूप में टिप्पणी में कहा:

// 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