Android Studio Adding Images

2019-07-22 19:46发布

问题:

I am new to android studio. Can any one tell me what is the best way to add images as in eclipse? We have different folder like mdpi, xdpi .. Can any one tell me what is the best way to add images and size also?

 I am trying with new->image asset but is this right way? what should be image size 

.. as in eclipse we are adding directly to res->mdpi,xdpi

What size should i take? What is asset type in that tool it giving only 3 option ie icon, action and tab, notification which one to be take?

回答1:

Just copy the image:

and paste it into drawable:

You can also drag and drop.

Now, for different sizes, just make a folder with the appropriate names. Go into project view first:

Then, see these little folders in the res?

Place each image into each folder. Here are the different size directories:

drawable-mdpi for medium-density

drawable-hdpi for high-density

drawable-xhdpi for extra-high-density

drawable-xxhdpi for extra-extra-high-density

Thats it.

If this helped, make sure to accept it by pushing the checkmark. If you have more questions, feel free to ask, I am happy to help!

Edit to question:

320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).  
480dp: a tweener tablet like the Streak (480x800 mdpi).  
600dp: a 7” tablet (600x1024 mdpi).  
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).


回答2:

You can directly Add your images in drawable folder OR If you have requirement for multi size images then use drawable size categories like.

drawable-mdpi for medium-density

drawable-hdpi for high-density

drawable-xhdpi for extra-high-density

drawable-xxhdpi for extra-extra-high-density

It can be found in detail Here