Skip to content Skip to sidebar Skip to footer

Android - Google Maps Inside Circleview

I wanted to show map inside a circle view where circle's outside area filled with a color. I referred a post Draw transparent circle filled outside. But now the problem is touch ev

Solution 1:

You could set a View.OnTouchListener to your RadiusOverlayView and calculate whether the RadiusOverlayView needs to manage the touch events or not. In this example I calculate this by testing if the RadiusOverlayView color touched is != 0 (maybe you want to improve this):

final RadiusOverlayView radiusOverlayView = (RadiusOverlayView) findViewById(R.id.radiusView);
radiusOverlayView.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(final View view, final MotionEvent motionEvent) {
        view.setDrawingCacheEnabled(true);
        Bitmap bmp = Bitmap.createBitmap(view.getDrawingCache());
        view.setDrawingCacheEnabled(false);

        return bmp.getPixel((int) motionEvent.getX(), (int) motionEvent.getY()) != 0;
    }
});

Post a Comment for "Android - Google Maps Inside Circleview"