0

So I am learning how to program android apps, and have just barely started. Looking through the developers page I followed a tutorial to add a search bar in the menu. However, it asked to put an image in the res/drawable folder. Upon seeing all these options I just placed it in the first folder, drawable-hdpi, and the app worked. I was just wondering if anyone could explain what the difference in each folder is, and if the icon is placed in the correct folder (even if the app still runs). Whats the most optimal solution?

https://i.stack.imgur.com/mJs1Q.jpg

Android Tutorial: http://developer.android.com/training/basics/actionbar/adding-buttons.html

Edit: Wow! Thanks for all the responses. You guys are fantastic. I'll mark an answer as soon as it will let me.

Tyler Jones
  • 424
  • 2
  • 10
  • 24
  • this may help you .... http://stackoverflow.com/questions/2025282/difference-between-px-dp-dip-and-sp-in-android?rq=1 – lalith Jan 08 '14 at 06:41

5 Answers5

3

The folder names need to be :

  • /drawable-ldpi For low density screens
  • /drawable-mdpi For medium density screens
  • /drawable-hdpi For high resolution screens
  • /drawable-xhdpi For extra high resolution screens

/drawable should be reserved for assets that you don't either care which device or for xml drawable assets

Then on top of that you can provide different resources based on configuration by using config qualifiers, you can read all about it here http://developer.android.com/guide/topics/resources/providing-resources.html

for instance, you can have high resolution assets for landscape with a folder

  • /drawable-land-hdpi

Hope that helps

M D
  • 47,665
  • 9
  • 93
  • 114
1

Android devices comes with different screen sizes and different resolutions. To support your application's images with different device's screen size you need to put your image in their respective folders. Following are the screen size supported by Android devices

  • LDPI ( deprecated )
  • MDPI : 48x48 Pixel
  • HDPI : 72x72 Pixel
  • XHDPI : 96x96 Pixel
  • XXHDPI : 144x144 Pixel
  • TVDPI

You can create such sizes images by helping of this site Android Asset Studio

Kitkat
  • 77
  • 16
  • Oh! So each folder is for different resolutions? Could I name different icons the same thing, place them in different folders, and it would pick the best one for the screen resolution? How can I find on what resolution different screens on? Currently I am developing on my S4, but I also have a tablet. Im trying to search.. – Tyler Jones Jan 08 '14 at 06:30
  • You can if you want to, but Android also re-scales automatically from any drawable folder. – Pieter Visagie Jan 08 '14 at 06:33
  • It's not correct if you make an image 48*48 pixel and it's ppi is 320 , then it will treated as XHDPI . Please edit your answer. It's action bar icon size only. Wrong answer – Satyaki Mukherjee Jan 08 '14 at 07:10
1

These different folders are for different screen sizes. Here is a link to the android notes, http://developer.android.com/guide/practices/screens_support.html .

In short the ldpi is for low resolution screens, mdpi for medium resolution and so on.

1

Android different Screen size with different resolutions:

 - drawable-ldpi (it need resolution or ppi is ~120)
 - drawable-mdpi (it need resolution or ppi is ~160)
 - drawable-hdpi (it need resolution or ppi is ~240)
 - drawable-xhdpi (it need resolution or ppi is ~320)

If you create big images but less ppi then it will go in this manner. So be aware about this.

Satyaki Mukherjee
  • 2,857
  • 1
  • 22
  • 26
0

this may help you ....

check out the answer in below link

What is the difference between "px", "dp", "dip" and "sp" on Android?

Community
  • 1
  • 1
lalith
  • 55
  • 7