Draw a transparent image on surface view
My objective is to run a glowing animation on an image.I am changing the image alpha to produce this effect.
I have used basic AlphaAnimatio开发者_Go百科n provided in android framework but found that its slowing down other animations. So i extended a class from SurfaceView and created a thread to update it. ( Again here, i am manipulating alpha of the image ).
Everything seems fine, except that i am not able to draw a transparent image onto SurfaceView.Its showing black color on the transparent areas of the bitmap.
Canvas mCanvas = holder.lockCanvas(null);
Bitmap mybit = BitmapFactory.decodeResource(mFrameLayout.getResources(), R.drawable.icon);
mCanvas.drawColor(0, Mode.CLEAR);
mCanvas.drawBitmap(mybit, 0, 0, null);
holder.unlockCanvasAndPost(mCanvas);
Thanks in advance.
There is an example of a Spinning cube in the samples. You should be have to have a look at that and see how they got a transparent background.
I haven't tried, but I assume you set the color of the Paint to a transparent one, and then use the Paint object to draw your bitmap.
精彩评论