我怎么能代替MyLocationOverlay的罗盘形象? [英] How can I replace the Compass image of MyLocationOverlay?

查看:130
本文介绍了我怎么能代替MyLocationOverlay的罗盘形象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用我的形象来代替MyLocationOverlay的罗盘形象,我怎么能实现?

I want to use my image to replace the Compass image of MyLocationOverlay, how can i implement?

推荐答案

子类MyLocationOverlay,覆盖的方法drawCompass(画布油画,浮动轴承),并得出自己的位图(S)到画布对象:

Subclass MyLocationOverlay, override the method drawCompass(Canvas canvas, float bearing), and draw your own bitmap(s) onto the canvas object:

@Override
protected void drawCompass(Canvas canvas, float bearing) {

    Resources res = _context.getResources();
    Bitmap myCompassPointer = BitmapFactory.decodeResource(res, R.drawable.compass_pointer);

    float rotationAngle = -bearing + 360f;
    Matrix rotation = new Matrix();
    rotation.preRotate(rotationAngle, myCompassPointer.getWidth()/2.0f, myCompassPointer.getHeight()/2.0f);

    canvas.drawBitmap(myCompassPointer, rotation, null);

    // don't call super if you don't want the default compass image:
    //super.drawCompass(canvas, bearing);

}

这篇关于我怎么能代替MyLocationOverlay的罗盘形象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆