2014-07-09 21 views
0

我想提請閃爍我的onDraw()內的位圖圖像,請通過下面的API,我能夠移動針上下幫助如何閃爍位圖箭頭圖像內的onDraw()

@Override 
protected void onDraw(Canvas canvas) { 
super.onDraw(canvas); 
bitmap= BitmapFactory.decodeResource(getResources(), 
      R.drawable.imagebitmap); 
bitmap = Bitmap.createScaledBitmap(pinMarker, 150,150, 
      true); 
canvas.drawBitmap(bitmap, left, top, paint) 
    } 



I'm expecting some gud suggestions from all of you :). 
+0

在自定義畫布上, – Arpana

回答

0
private void clueFoundPinNotification(Canvas c, float x, float y) { 
    float newY = 0;int yVelocity = 30; 
    //Load image in bitmap  
    if (mPinPointer == null) { 
     mPinPointer = BitmapFactory.decodeResource(getResources(), 
       R.drawable.pointer); 
     mPinPointer = Bitmap.createScaledBitmap(mPinPointer, 40, 40, true); 
    } 
    // my requirement was move pin up-down so I used y coordinate only 
    if (newY <= 0) 
     newY = y - 80; 
    newY += yVelocity; 
    if ((newY > y - 70) || (newY <= y - 80)) { 
     yVelocity = yVelocity * -1; 
    } 

    c.drawBitmap(mPinPointer, x + 15, newY, null); 
    Log.i(TAG, "clueFound-x " + x + "clueFound-y " + y); 

}