I'm developing a custom view and I need to draw drawables inside. Those drawable must have their position relative.
Here is my code :
@Override
protected void onDraw(Canvas canvas) {
//drawBackground(canvas);
float height = (float) getHeight();
float width = (float) getWidth();
canvas.save(Canvas.MATRIX_SAVE_FLAG);
canvas.scale(width, height);
drawFlowChart(canvas);
drawDrawables(canvas);
canvas.restore();
}
private void drawDrawables(Canvas canvas) {
canvas.save(Canvas.MATRIX_SAVE_FLAG);
Resources res = getResources();
Bitmap bitmap = BitmapFactory.decodeResource(res, R.drawable.motor);
canvas.drawBitmap(bitmap, 0.51f, 0.35f, null);
canvas.restore();
}
But it draw nothing. Any idea ?
I tried to use the drawBitmap(bitmap, src, dest, paint) but I don't know how to position my bitmap with relative position with this definition.