Android Studio 1.3
Hello,
I have taken some pictures from my Nexus 5 phone. I would like to use one for as a header that is loaded into a imageview.
However, I am not sure about the scaling and which drawable-xhdi, drawable-xxhdi etc, it should go in.
The picture I have currently is:
Width: 3200 pixels
Height: 2368 pixels
Size: 2.4 MB
file type: jpg
I have gimp photo edit tool that I can compress into a png file to reduce the size. But I am not sure how can I make the picture look good on other screen densities. Which drawable folder would I have to put each one in?
Many thanks for any suggestions,
To import image resources into your project, do the following: Drag and drop your images directly onto the Resource Manager window in Android Studio. Alternatively, you can click the plus icon (+), choose Import Drawables, as shown in figure 3, and then select the files and folders that you want to import.
Supported file types are PNG (preferred), JPG (acceptable), and GIF (discouraged).
Drawable drawable = ResourcesCompat. getDrawable (res, R. drawable. myimage, null);
ImageView class is used to display any kind of image resource in the android application either it can be android. graphics. Bitmap or android. graphics. drawable.
1st of all, you should know there is a limit on image size :
OpenGl maximum size is 2048x2048 or else it throws an error: Bitmap too large to be uploaded into texture.
2nd you must consider, what are devices you are targetting for. There are different qualifiers in android:
Screen size: Actual physical size, measured as the screen's diagonal. For simplicity, Android groups all actual screen sizes into four generalized sizes: small, normal, large, and extra-large.
Screen density The quantity of pixels within a physical area of the screen; usually referred to as dpi (dots per inch). For example, a "low" density screen has fewer pixels within a given physical area, compared to a "normal" or "high" density screen. For simplicity, Android groups all actual screen densities into six generalized densities: low, medium, high, extra-high, extra-extra-high, and extra-extra-extra-high.
3rd look at Android Dashboard.
Quick look reveals, that are few ldpi and almost none xxxhdpi devices. What does it mean? You don't need to provide resource for those folder. But do as you like.
Note: You do not need to provide xxxhdpi assets for all your app's images.
4th Look at your application and find out the maximum size:
So if your image is going to be a header, I assume it will match_parent -> Let's say, you are designing your app to work on screen resolutions 1920*1080 (h*w) and lower. Now you see first important step. If your image matches_parent and parent is maximum 1080px wide, you don't need 3200 px wide image!
5th Resize the image using some tool like 9-Patch-Resizer or Android Asset Studio and add it to your drawable folders
6th Test it on devices and check if the image quality is good enough. On tablets, you might consider to use drawable-large and drawable-xlarge folder.
- 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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With