I use Picasso to retrieve the Bitmap image to use as a marker icon and it apply successfully. But I need to dynamically increase the size of the custom marker for all devices. Because with my code below, it's working fine in some devices but in some others devices, the marker is very big.
Here's my code
dest = new LatLng(myMarker.getmLatitude(), myMarker.getmLongitude());
markerOption = new MarkerOptions().position(dest);
location_marker = mMap.addMarker(markerOption);
Target target = new PicassoMarker(location_marker);
targets.add(target);
Picasso.with(MapsActivity.this).load(myMarker.getmIcon()).resize(84, 125).into(target);
mMarkersHashMap.put(location_marker, myMarker);
Please help me to fix the issue.
Thanks in advance.
As per the code you provided, you can just modify the value you passed in the
resize()
in this line:I tried it out, your code shows this:
Then I modified the value of in the
resize()
, like so:And it turned out like this:
The value to pass in
resize()
all depends on you. ;)If your concern is on what value to pass depending on the screen size, You can refer to this answer from a different post. Here's what it says --
You can do this with
LayoutParams
in code. Unfortunately there's no way to specify percentages through XML (not directly, you can mess around with weights, but that's not always going to help, and it won't keep your aspect ratio), but this should work for you:-- It's quite a good example, simply measure the layout to use it as reference on how you will size the image.