Ad

Thursday, August 2, 2018

Android ImageView with Drawable images

The goal is for mobile developers to load images onto mobile applications when limited memory is available.

Android drawable images @drawable/my_img can be set as the source of an ImageView. Image file extension is optional. Drawable refers to the fact that the image can be drawn on the screen. Android manage all drawables in a res/drawable directory.
https://developer.android.com/guide/topics/resources/drawable-resource

Drawable supports mainly bitmap format including .jpg, .png, .gif. The unit element for these images is a pixel.

Density independent pixels (DIP) allows ImageView to scale and resize across screen sizes and pixel densities - across the wide variety of Android devices. Specifying button size using dp instead of px make sure the button is still reasonably sized and clickable on high resolution high density screens (high number of dots or pixels per inch).

Best practice to keep file size small is to include different image sizes for handling different dip's. Android does this automatically and load the corresponding dip drawable assets into the right folder: hdpi, mdpi, xhdpi, xxhdpi.

Developers also use ImageMagik to compress photos and Android Drawable Importer to convert images to drawable https://plugins.jetbrains.com/plugin/7658-android-drawable-importer

No comments:

Post a Comment

Password protect and zip compress files on Mac

The following step is only recommended for developers who have experience working in the command line. This is the build-in zip compress and...