Can background images be used with google asset studio - android

I have some background images that have been designed using Photoshop. I did the same image using Illustrator that uses vector graphics, but when deployed the image did not scale very well. Sometimes too big or small. From experimenting, the photoshop images looked much better, even though it used raster images.
I have set the layout background property to this:
android:background="#drawable/camera"
I have just a few questions:
What is better for creating background images, photoshop (raster) or Illustrator (vector)?
As all smart devices are different dpi's and sizes. Is what recommended size should I create the original image when designing it in photoshop or Illustrator?
I noticed that asset studio can create scalable images but can the icon launcher be used for background images, or is it only for launcher icons?
Android Studio 0.5.4

This depends on what your final image should look like or which
tool is better suited for your needs. PS is more suitable to create
pixel graphics and IL is better used for shapes, buttons and so on. In the
end it doesn't matter for android, because internally graphics are
interpreted as bitmaps and therefore are pixel-based. Android
unfortunately doesn't support SVG by default, although there are libs
available.
You should have a look at the supported screens range
http://developer.android.com/guide/practices/screens_support.html#range
You can't really create background images that fit every screen but at least you can approximate them, so only some parts of the image are cut off eventually. Alternatively you can use 9drawables to stretch an image to fit every screen. In that case you will need an image with stretching marks as described here: http://www.vogella.com/tutorials/AndroidDrawables/article.html#drawables_9patch
Asses Studio is best used for Icons. However you could use it for generating the above mentioned 9drawables in the correct sizes: http://android-ui-utils.googlecode.com/hg/asset-studio/dist/nine-patches.html

Related

Android image drawable for various resolutions

For using images in my android application, I will use this technique :
I put all of my images into "drawable-xhdpi" folder to let the application scale the images down for various resolutions.
I wondering does it make sense ? What is your experiences ?
Thanks for sharing...
UPDATE:
Maybe this method is a nice one, But an another question raises here which is :
Does this technique causes a memory leak for ldpi devices? I don't want to solve the problem by using svg images, Suppose there are bit-mapped images which are not vector based and there is no choice or alternative to replace. using a bitmap is the only choice.however using this method has a cons which will affect the overall layout and in some devices the position of relevant controls will be changed.
While this will work, it's not ideal and not recommended. Please look at the official documentation for Supporting Multiple Screens:
Although the system performs scaling and resizing to make your application work on different screens, you should make the effort to optimize your application for different screen sizes and densities. In doing so, you maximize the user experience for all devices and your users believe that your application was actually designed for their devices—rather than simply stretched to fit the screen on their devices.
And:
Provide different bitmap drawables for different screen densities
By default, Android scales your bitmap drawables (.png, .jpg, and .gif files) and Nine-Patch drawables (.9.png files) so that they render at the appropriate physical size on each device. For example, if your application provides bitmap drawables only for the baseline, medium screen density (mdpi), then the system scales them up when on a high-density screen, and scales them down when on a low-density screen. This scaling can cause artifacts in the bitmaps. To ensure your bitmaps look their best, you should include alternative versions at different resolutions for different screen densities.
You can use the File / New / Image Asset to automatically generate the scaled assets.
Best way is use SVG files instead of PNG and import them to project in Androis studio: File -> New -> Vector Asset or use icon fonts like https://github.com/mikepenz/Android-Iconics
SVG file is inserted to drawable and converted to PNG files while compile time for back compatibility, but you don't need to maintain a pack of files, but just one vector file.
I use inkscape to create svg drawings and also to convert to png I think the conversion has better quality and supports all svg functions.
With inkscape and a script it is possible to do batch conversion, I have not tried it yet, until now I convert them one by one

Using fontawesome (icons) in game, in theory

The font-awesome icons are vector based, and from my understanding vector iamges are bad in apps since they are very big (in bytes), is this true
for fontawesome icons? In theory, could I use these icons in my game, not only for menu buttons and such, but also for actual game graphics?
I'm planning on doing a very simple game, and I'd hate to get stuck on the design part, not only the drawing of them, but I've had trouble with scaling of
images (according to screen size) in the past, vector images would solve this.
I realize icons are not optimal for game graphics, but would it be usable?
Vector based images are usually smaller than bitmap based images, because they just contain an abstract description of the image content, that can be scaled to virtually any size.
Your graphics card does not understand these kind of image formats though. You would have to convert them to a bitmap based format first, which means you have to set a specific size for the resulting image.
LibGDX offers the FreeType extension, to convert TrueType font files (.ttf) at runtime to a BitmapFont with a specific size, which can then be rendered.
That way you will be able to generate icons on the fly for the correct display size, without having to ship many different versions of them, for different resolutions.

Is there any difference between svg and png img?

I am working on a project and dont know which img to use for my icons.
I have already tried searching the web but could not find the exact differnece.
SVGs are vectors, meaning they’re completely customizable. Change the size to big or small, change the colors, or even change the shapes themselves. They will not pixelate as they scale making it great for multiple devices
PNGs come as they are. You can paste or place in any program with any background. You can’t really change the color or shape or the shape and if you try to make them bigger, they will pixelate.
Android does not support SVG. PNG simply for the fact it seems to be a more accepted format than SVG. SVG is scalable, if you have a vector-graphic that is a clear advantage. For pixel-graphics PNG is better but you could create one graphic that looked great on a tiny mobile phone screen or on a 60-inch computer monitor.

How to reduce my android apk size..?

I have used lots of images in my android application and now my application size is too big. How can I reduce my android app size without deleting the images
Some advices that might be helpful:
Take advantage of xml drawables (reference), whenever possible.
Use SVG graphics, if possible. Vector graphics is usually smaller than bitmap graphics. And it will allow to use a single image for all resolutions, due to its intrinsic scalability. You will need a small 3rd party library, like androidsvg or similar ones.
Use 9 patches (tutorial) when you can, and you will save a lot of (normally wasted) pixels in your backgrounds.
Shrink your PNGs with a tool like OptiPNG or similar. They shrink your graphics preserving quality.
And more:
Remove any debug info.
Avoid duplicated code.

Why should I create android icon for different device sizes?

All I do is scale image using GIMP and put them into hdpi, ldpi and mdpi. Is there a good reason for bundling icons of all different sizes into the package, since I do not correct the pixels after resizing?
In android we have a tool called NinePatch here we use a single image for all the type of screen resolution. just you need to create an image using Ninepatch tool. The NinePatch image will have an extension .9.png
In Android we have phones of different resloution and a single app/code we develop supports multi resolution in order to maintain in the image clarity we need to have images in hdpi,mdpi,ldpi
Even if you don't export your vector images into your icon files directly to have the best quality, resizing them in Gimp is still better than just using one icon in your project, because the scaling of a dedicated image processor (like Gimp2) will always be better than what Android can do natively for you.
If you scale down from a higher resolution then it's ok.
But if you scale up from a lower resolution then it will just look bad on those devices.

Categories

Resources