Reputation: 503
i have a bitmap, that is perfectly displayed inside my 7'' inch tablet, but different in other devices, it is a screen issue, but i don't understand how to fix.
i retrieve this bitmap, by URL in this way
URL url = new URL(...);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
overlay = BitmapFactory.decodeStream(input);
connection.disconnect();
and after i do this
bitmapMarker = BitmapFactory.decodeResource(context.getResources(), R.drawable.marker);
newMarker = bitmapMarker.copy(Bitmap.Config.ARGB_8888, true);
canvas = new Canvas(newMarker);
canvas.drawBitmap(overlay, 14, 8, null);****** -> THIS CANVAS IS NOT DISPLAYED WELL IN DIFFERENT DEVICES***********
marker = map.addMarker(new MarkerOptions().position(position).title(title).snippet(snippetText).icon(BitmapDescriptorFactory.fromBitmap(newMarker)));
thanks in advance.
Upvotes: 0
Views: 98
Reputation: 981
You should look into the android device size resolutions. Each device knows which resolution it uses. By using a method that can get one of the images based on the resolution of the current device, you can get differently sized images that are appropriate for the current device.
getImage(getResources().getDisplayMetrics().densityDpi);
For learning more about supporting different screens, this is a good place to start. At the very least pay attention to the ratios between the different screen sizes for scaling purposes (i.e. mdpi is 25% the size of xxxhpdi).
Upvotes: 1
Reputation: 8882
Can you change
canvas = new Canvas(newMarker);
canvas.drawBitmap(overlay, 14, 8, null);****** -> THIS CANVAS IS NOT DISPLAYED WELL IN DIFFERENT DEVICES***********
to
canvas = new Canvas(newMarker);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setFilterBitmap(true);
paint.setDither(true);
canvas.drawBitmap(overlay, 14, 8, paint);
and see if that fixes the issue? I think android by default on some platforms will scale to fill, but not on others.
Upvotes: 1