java - 如何用图像中的蓝色半透明圆替换我的 Android 应用 Google map 半径圆?

标签 java android eclipse google-maps

如何将我的 Android 应用 Google map 半径圆替换为蓝色半透明圆,如图像中的蓝色标记和蓝色圆?

我可以让圆圈具有特定的轮廓和填充,但它看起来远没有下图所示的那么漂亮。我怎么做?到目前为止,我的代码也在下面。

代码:

    private GoogleMap googleMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        try {
            initilizeMap();

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
    private void initilizeMap() {
        if (googleMap == null) {
            googleMap = ((MapFragment) getFragmentManager().findFragmentById(
                    R.id.map)).getMap();


              LatLng latLng = new LatLng(28.982518, -81.542272);
              gooleMap.addMarker(new MarkerOptions().position(latLng));


              Circle circle =  gooleMap.addCircle(new CircleOptions()
              .center(new LatLng(28.982518, -81.542272))
              .radius(1000)
              .strokeColor(Color.RED)
              .fillColor(Color.PURPLE));

mMap.addCircle(new CircleOptions()
        .center(center)
        .radius(radius)
        .strokeWidth(0f)
        .fillColor(0x550000FF));

        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        initilizeMap();
    }

}

安卓 xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</RelativeLayout>

图片:

enter image description here

为了确认,我要做的是:

显示上面的效果,深蓝色圆圈,半透明浅蓝色填充,如上图

最佳答案

    CircleOptions circleOptions = new CircleOptions()
        .center(latlng)
        .radius(500)
        .strokeWidth(2)
        .strokeColor(Color.BLUE)
        .fillColor(Color.parseColor("#500084d3"));
        // Supported formats are: #RRGGBB #AARRGGBB
        //   #AA is the alpha, or amount of transparency

    mMap.addCircle(circleOptions);

translucent blue circle

关于java - 如何用图像中的蓝色半透明圆替换我的 Android 应用 Google map 半径圆?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21907317/

相关文章:

java - 在 AsyncTask 中捕获未处理异常的设计模式

java - 处理 AsyncCallback<T>?

java - java中简单日期格式的问题

android - 由于 newrelic 异常,应用程序在 onCreate 中崩溃

java - Tomcat 是如何管理 session 的?

java - 如何使用另一个 jar 文件启动和停止一个 jar 文件?

java - onStartListening 什么时候调用?

android - 如何查看 "if image gallery is empty"

eclipse - Hadoop & eclipse 在不同的机器上

android - 如何在 Eclipse 中关闭 ADB 控制台的自动显示?