1

https://developer.android.com/training/basics/actionbar/adding-buttons.html

The icon attribute requires a resource ID for an image. The name that follows @drawable/ must be the name of a bitmap image you've saved in your project's res/drawable/ directory. For example, "@drawable/ic_action_search" refers to ic_action_search.png.

how to add image to res/drawable/ ?? What size image needed for each type, like xxxdpi,xxdpi

Himanshu Joshi
  • 3,291
  • 1
  • 17
  • 31
Hon
  • 98
  • 1
  • 12
  • 2
    Just take a look at this link, upload the image and download the res folder completely http://romannurik.github.io/AndroidAssetStudio/ – George Thomas Aug 21 '15 at 08:42

6 Answers6

2

For your First Answer Please Visit Android ImageView example.Copy the image and paste into Eclipse/Android-Studio in the res/drawable directory.

The image name should be in lowercase, otherwise it will end up with an error.

You should always provide bitmap resources that are properly scaled to each of the generalized density buckets: low, medium, high and extra-high density. This helps you achieve good graphical quality and performance on all screen densities.

To generate these images, you should start with your raw resource in vector format and generate the images for each density using the following size scale:

  1. xhdpi: 2.0
  2. hdpi: 1.5
  3. mdpi: 1.0 (baseline)
  4. ldpi: 0.75

This means that if you generate a 200x200 image for xhdpi devices, you should generate the same resource in 150x150 for hdpi, 100x100 for mdpi, and 75x75 for ldpi devices.

Then, place the files in the appropriate drawable resource directory:

Project/
    res/
        drawable-xhdpi/
            awesomeimage.png
        drawable-hdpi/
            awesomeimage.png
        drawable-mdpi/
            awesomeimage.png
        drawable-ldpi/
            awesomeimage.png

Any time you reference @drawable/awesomeimage, the system selects the appropriate bitmap based on the screen's density.

For more details

http://developer.android.com/guide/practices/screens_support.html

enter image description here Reference

Community
  • 1
  • 1
IntelliJ Amiya
  • 70,230
  • 14
  • 154
  • 181
1

You should consider mdpi as you base and using that you can create for hdpi, xhdpi and so on eg. if you mdpi size is 12px X 12px then for hdpi it should be 18px X 18px as hdpi is 1.5 times mdpi

use this link About Android image and asset sizes

Community
  • 1
  • 1
1

Drag drop image using finder/explorer Use android design guidlines for icon size ratios

Mayank Metha
  • 162
  • 11
  • Just to add to this, android studio will not allow you to make use of a resource that has upper case letters in the file name. – James Wolfe Aug 21 '15 at 08:55
0

Just copy your images from your syaytem to drawable directory of your project

And for icon sizes you can refer to this answer https://stackoverflow.com/a/12768159/4211264

Community
  • 1
  • 1
Bhargav Thanki
  • 4,552
  • 2
  • 31
  • 43
0

What size image needed for each type, like xxxdpi,xxdpi

for icon size.. please refer this site

http://iconhandbook.co.uk/reference/chart/android/

uday
  • 1,288
  • 10
  • 23
0

Go to YourProjectName/res/drawable and save your image in this folder. If u have different sizes you can also use the different drawable folders.

If it is one image for every size just create the new folder "drawable" and save your image there.