ful*_*gen 4 android google-maps google-maps-android-api-2
我在此链接中找到了此代码https://developers.google.com/maps/documentation/android/shapes#customizing_appearances
Polyline line = map.addPolyline(new PolylineOptions()
.add(new LatLng(-37.81319, 144.96298), new LatLng(-31.95285, 115.85734))
.width(25)
.color(Color.BLUE)
.geodesic(true));
Run Code Online (Sandbox Code Playgroud)
我的问题是颜色在Color.Blue返回一个错误,说颜色没有出现在当前的背景下存在的名称.
只需在colors资源文件中定义颜色并执行以下操作:
PolylineOptions rectLine = new PolylineOptions().width(4).color(context.getResources().getColor(R.color.cyan));
Run Code Online (Sandbox Code Playgroud)
对我来说很棒.
我已经解决了我的问题。
首先,我在值文件夹 Color.xml 中创建了一个 xml 文件
颜色.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="blue">#0000EE</color>
</resources>
Run Code Online (Sandbox Code Playgroud)
然后在我的活动中
Polyline line = map.addPolyline(new PolylineOptions()
.Add(new LatLng(-37.81319, 144.96298), new LatLng(-31.95285, 115.85734))
.InvokeColor(Resources.GetColor(Resource.Color.blue));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16774 次 |
| 最近记录: |