How to draw a background canvas of the same color in android

I am trying to have a single color bg canvas, but it does not work. Perhaps I can create an array of the same color and bitmap, but if possible I would like to avoid this. RE: Android canvas background color

private void addCustomMarker(GoogleMap map, ActivePoint a, LatLng latLng) { Bitmap.Config conf = Bitmap.Config.ARGB_8888; Bitmap userBmp = Utils.decode(a.mCreatorUser.getmImgBase64Thumb()); Bitmap dogBmp = Utils.decode(a.mCreatorDog.getmImgBase64Thumb()); int border_width = 10; int width, height = 0; width = userBmp.getWidth() + dogBmp.getWidth(); height = userBmp.getHeight() > dogBmp.getHeight() ? userBmp.getHeight() : dogBmp.getHeight(); Bitmap cs = Bitmap.createBitmap(width+border_width*2, height+border_width*2, Bitmap.Config.ARGB_8888); Canvas canvas1 = new Canvas(cs); // modify canvas canvas1.drawARGB(0, 0x3F, 0x51, 0xB5); // canvas1.drawColor(ContextCompat.getColor(this,R.color.primary), PorterDuff.Mode.CLEAR); // add marker to Map map.addMarker(new MarkerOptions().position(latLng) .icon(BitmapDescriptorFactory.fromBitmap(cs)) // Specifies the anchor to be at a particular point in the marker image. .snippet(a.mId) .anchor(0.5f, 1)); } 
+1
source share
1 answer

PorterDuff.Mode.CLEAR makes it transparent, so you donโ€™t see them while they are on the map, remove this argument.

0
source

Source: https://habr.com/ru/post/981615/


All Articles