hello guys I'm stuck on a simple problem which is driving me nuts.You know in andoid MapView may have overLay image on the map,moreover image has a shadow when you call DrawAt method. I also want to get that effect,but my image and shadow is detached,how to make them near to each Other. As follow code you can get two image, how to make the image (called DrawShadowImg(canvas,nX, nY) ) near to the other image(called DrawNormalImg(canvas, nX, nY)),because my code make them separate,so donot have separate effect
private static class SampleView extends View {
private Drawable mDrawable ;
private int mMarkerXOffset;
private int mMarkerYOffset;
public SampleView(Context context) {
super(context);
mDrawable=context.getResources().getDrawable(R.drawable.icon);
mDrawable.setBounds(0, 0, mDrawable.getIntrinsicWidth(), mDrawable.getIntrinsicHeight());
mMarkerXOffset = (mDrawable.getIntrinsicWidth() / 2);
mMarkerYOffset = mDrawable.getIntrinsicHeight();
}
private void DrawNormalImg(Canvas canvas, int nX, int nY)
{
canvas.save(Canvas.MATRIX_SAVE_FLAG);
canvas.translate(nX, nY);
mDrawable.draw(canvas);
canvas.restore();
}
private void DrawShadowImg(Canvas canvas, int nX, int nY)
{
canvas.save(Canvas.MATRIX_SAVE_FLAG);
mDrawable.setColorFilter(0x7f000000, PorterDuff.Mode.SRC_IN);
canvas.translate(nX,nY);
canvas.skew(-0.9F, 0.0F);
canvas.scale(1.0F, 0.5F);
mDrawable.draw(canvas);
mDrawable.clearColorFilter();
canvas.restore();
}
@Override protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.WHITE);
int nX = 100;
int nY = 50;
DrawShadowImg(canvas,nX, nY);
DrawNormalImg(canvas, nX, nY);
}