问题
I am drawing multiple polylines using for loop on version 2 google map. I am setting color to the polyline using the code.
mMap.addPolyline(new PolylineOptions()
.add(new LatLng(lats, lons), new LatLng(late,lone))
.width(5)
.color(0xFFFF0000));
How to increment the RGB color dynamically for each for loop iteration.
回答1:
Random rnd = new Random();
int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
--- loop ----
mMap.addPolyline(new PolylineOptions()
.add(new LatLng(lats, lons), new LatLng(late,lone))
.width(5)
.color(color));
来源:https://stackoverflow.com/questions/16214275/draw-polylines-with-different-colors-on-v2-maps