Reputation: 105
I have a class called Preview that is added as a child to one of my FrameLayouts. This is the Preview's onDraw method. fingerprint.png is in my drawable folder, and
protected void onDraw(Canvas canvas) {
System.out.println("on draw");
Resources res = getResources();
fingerprint = res.getDrawable(R.drawable.fingerprint);
fingerprint.draw(canvas);
//fingerprintScaled.draw(canvas);
}
"on draw" prints, but the fingerprint image is not rendered.
Upvotes: 1
Views: 2378
Reputation: 1215
The reason it is not drawing is because you are calling draw wrong. in protected void onDraw(Canvas canvas) do something like this (except dont decode stuff in onDraw)
Bitmap fingerprint = BitmapFactory.decodeResource(context.getResources(),R.drawable.icon_resource);
canvas.drawBitmap (fingerPrint, aMatrix, paintToDraw);
this should draw your bitmap properly.
Upvotes: 3