Android BitMapDescriptor from XML shape transparent is black

狂风中的少年 提交于 2019-12-08 12:17:59

问题


So this bitmapdescriptor when used in a Groundoverlay on GoogleMap (v2) the transparency is being shown as black can anyone explain why?

Radius Circle shape file

   <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">

    <gradient android:startColor="@color/brand_color" android:endColor="@android:color/transparent" android:type="radial" android:gradientRadius="110"/>

</shape>

place on Map

if (mDotMarkerBitmap==null){
                                int px = getResources().getDimensionPixelSize(R.dimen.pin_radius_drawable);

                                mDotMarkerBitmap = Bitmap.createBitmap(px, px, Bitmap.Config.ARGB_8888);
                                Canvas canvas = new Canvas(mDotMarkerBitmap);
                                Drawable shape = getResources().getDrawable(R.drawable.radius_circle);
                                shape.setBounds(0, 0, mDotMarkerBitmap.getWidth(), mDotMarkerBitmap.getHeight());
                                shape.draw(canvas);
                            }

                            BitmapDescriptor descriptor = BitmapDescriptorFactory.fromBitmap(mDotMarkerBitmap);


                            GroundOverlay groundOverlay = mMap.addGroundOverlay(new GroundOverlayOptions()
                             .image(descriptor)
                             .transparency(0.4F)
                             .position(center, radiusDistance.distanceInMeters*2));

I can't seem to understand why this is being malformed I just want it to fade out from inner to out, however it is fading from color to grey (black but transparent)


回答1:


Hmmm ok the answer seemed to be to set the end color to a hard transparency rather than relying on

android:endColor="@android:color/transparent" 

I changed the end color to this

android:endColor="#00FFFFFF"


来源:https://stackoverflow.com/questions/19198447/android-bitmapdescriptor-from-xml-shape-transparent-is-black

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!