0

I am new to Android and I need some advice on how to work with images.

  1. I have a button which layout_width is match_parent. The button has rounded corner. So what image size should I choose to render the button so that in all devices it will look fine? Note: on this button I can't use 9 patch images. I don't want to use a 9 patch.

  2. When I set my logo in a listview it is stretched and it appears very ugly. Let's say the image size which comes from server is 400x400 px wide. What should I do to scale the image to look fine in all devices?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
  • attach how the logo appears as streched.. – Vikas B L Dec 23 '13 at 10:33
  • Are you using button tag? If you want to display image in the button, you better use imageview and make the image you want to use as button as background. – Vikas B L Dec 23 '13 at 10:35
  • let's say I have green gradient background which corners are rounded. I want button looks fine in all device – user3024382 Dec 23 '13 at 10:44
  • Yes. As described below resolution, make image button to the standard resolution. That will work. Since android devices vary in resolution, below are the standards which most of the mobile uses. – Vikas B L Dec 23 '13 at 10:51
  • according your answer I have to create 4 types of button and put it in ldpi,mdpi,hpdi,xhdpi folder? – user3024382 Dec 23 '13 at 11:16
  • Yes. You are right. Google for most standard screen resolutions of mobile. – Vikas B L Dec 23 '13 at 11:21

1 Answers1

1

You can baseline the image sizes for a particular resolution, say mdpi. Then scale the images for other resolution as,

ldpi = mdpi*0.75
hdpi = mdpi * 1.5
xhdpi = mdpi * 2

NB- Use 9 patch images wherever possible to avoid this overhead of creating multiple images.

nikvs
  • 1,090
  • 5
  • 9
  • in this point I can't use 9 patch images for some reasons. let's say I have button and I want put background gradient image. What size should I create my image to work fine to all devices. – user3024382 Dec 23 '13 at 10:47
  • without using 9 patch , the only way to go, is creating multiple size version of the same button image(based on the points in my answer) and put them in their respective resource folders. – nikvs Dec 23 '13 at 11:33