Is it image or can we develop it as drawable? - android

I want to develop same UI like this.
In this UI you can see yellow shaded style on right up corner. I want to ask that how can I develop this type of asset in android?

You can do both or even import an SVG which is usually my preferred way. On the link i passed you will see examples of all different methods so I will just give you quick summary here.
If you decide for image-based formats like JPEG,PNG... you will have to import it multiple times for different screen sizes in order not to lose sharpness which will take more storage space
If you decide for vector based graphics like Xml drawables from android or SVG, you end up with more flexibility and programmability of your graphic and less storage space needed. However it can decrease performance of the app if graphic is complicated (not in your case yours is super simple) because it uses computing power to render the vectors instead of just showing file from storage

Related

How to reduce Android app size by compressing images?

I am developing an Android app which has hundreds of .jpg files (over 300) each one of around 40kB. I would like to know if there is a way of reducing the size of my app. I looked at a similar question here Reducing Android App Size, but the problem still exists. Is there perhaps a way to compress the images and decompress them in real time when needed, or any other way to make my app more space efficient while not sacrificing speed?
If you have used tinypng for every resource you did your best with this kind of solution. In general, it's better to use vector graphics where the general icon will be <1kb. Also, a vector resource can be animated. If it's quite simply bitmaps, you can generate them in code on demand. Also, you can divide your app by dynamic features and each will be downloaded on demand with their part of the resources.
Is there perhaps a way to compress the images and decompress them in real-time when needed?
There is no standard Android solution out of the box. Probably, you can write something on your own. But this looks like too much effort.
Still, the most practical solution: use vector graphics as max as possible, generate in code what you can generate, compress with tinypng the others. That should be enough or you should have a very good reason for making some extra work.
For more info about vector graphics in android. For standard vector graphic import right in the android studio.
Web-site where you can download icons and insert them into the project.

android: what's preferred, loading custom font or image?

What is a best practice when it comes to weird fonts?
I have to show a unique font on a splash page only, it's a .otf font. What's better (if a discriminator for "better" is needed, let's look at it from the point of view of performance, but any feedback is welcome), have a picture of my text on the splash screen (I already learnt I need to provide images for every supported screen size), or to have a font loading throught Typeface.createFromAssets()?
I know "what's better" questions are always a bit ambigous, but in this case it's a rather specific question - otherwise I apologize.
Not sure why you call the font you want to use "weird" rather than just "custom", but: if you need to shape lots of text with it, just use the font itself provided you may do so. Not every font you pull off the web lets you do what you want just because you found it for free, make sure to do your homework and check whether the font actually has license terms or costs money. If all you need it for is the splash page, then an image might make more sense, provided it's smaller than the font itself. If it's bigger, you might as well save space and use the real font.

I have a map that's a vector image. Whats the best way of showing this in android?

I want to add a vector that's a map. I want to show this to the user, but I'm unsure of the best way to do this.
The only requirements I have are:
Show a vector
Start "zoomed" in (start at a specific point of the the map)
Work on 4.0 and up
I'm up for suggestion on which file type to use
Ah, that is definitely not how I interpreted "I don't want to specify one".
SVG is probably the lightest-weight solution. There are libraries that can display SVG in an ImageView as a Drawable, though these will only handle a subset of SVG. WebView on Android 3.0+ is supposed to be able to handle SVG files, though I haven't tried it.
Many, perhaps most, Android users have a PDF viewer, so if you're willing to open up a third-party app, you can do that easily enough. There are PDF libraries as well, though PDF is a more complex file format than is SVG, and therefore the libraries suffer.
I am not aware of any easy way to show an AI file directly, and those are the primary 2D vector formats in use today.

Using SVG files with libgdx

I'm planing to create tablet app. I would ask for some guidance.
I have pictures in SVG format like this one.
With SVG it is easy, You just change fill parameter to different color but as I understand, there is no easy/stable svg processing to use with libgdx. I still want to use svg files to create/store images for my app.
What processing path would You recommend?
Is there an easy way to convert svg paths/shapes for com.badlogic.gdx.math.bezier or polygon objects and then draw them on screen/get user input (tap) inside this shapes?
Or should I use different objects/path?
Shapes could be grouped together for example I want two windows in a house to change color at once.
The way LibGDX is written is it gives you a lower level way to do this type of rendering, but doesn't offer out of box ways to render SVG. It really depends on if you are looking for something with performance or just simply want it to draw basic shapes.
To simply render shapes you could use something like ShapeRenderer. Which gives you a very close interface to the Java2D way to draw things. Maybe to quickly draw some basic stuff this might be handy.
If you are wanting to do some more robust version of rendering you will probably want to look into using a Mesh and working with shaders for OpenGL ES. You can find examples of these in the LibGDX tests as well as searching online for examples/tutorials.
If you want to turn the SVG into a texture you will want to look at Pixmap and then you can create a Texture with it and render with a Spritebatch. You will need to write the pixels you want to color and such with the Pixmap. However, doing it this way will generate an unmanaged texture (i.e. you will have to rebuild it when a user comes back to the app after pressing back or putting the device to sleep).

Android efficient storage of two images which are similar

Application size on a phone needs to be as small as possible. If I have an image of a sword and then a very similar image of that same sword except that I've changed the color or added flames or changed the picture of the jewel or whatever, how do store things as efficiently as possible?
One possibility is to store the differences graphically. I'd store just the image differences and then combine the two images at runtime. I've already asked a question on the graphic design stackexchange site about how to do that.
Another possibility would be that there is that apk already does this or that there is already a file format or method people use to store similar images in android.
Any suggestions? Are there tools that I could use to take two pngs and generate a difference file or a file format for storing similar images or something?
I'd solve this problem at a higher level. For example, do the color change at run-time (maybe store the image with a very specific color like some ugly shade of green that you know is the color to be fixed at run-time with white or red or blue or whatever actual color you want). Then you could generate several image buffers at load-time.
For compositing the two images, just store the 'jewel' image separately, and draw it over the basic sword. Again, you could create a new image at load-time, or just do the overdraw at run-time.
This will help reduce your application's footprint on flash, but will not reduce the memory footprint when the app is active.
I believe your idea of storing the delta between 2 images to be quite good.
You would then compress the resulting delta file with a simple entropy coder, such as Huffman, and you are pretty likely to achieve a strong compression ratio if similarities with base image are important.
If the similarity are really very strong, you could even try a Range Coder, to achieve less-than-one-bit-per-pixel performance. The difference however might be noticeable only for larger images (i.e higher definition than a 12x12 sprite).
These ideas however will require you or someone to write for you such function's code. This should be quite straightforward.
An very easy approach to do this is to use an ImagePack ( one image containing many ) - so you can easy leverage the PNG or JPG compression algorithms for your purpose. You then split the images before drawing.

Categories

Resources