Using Vector Images in SUSI Android
Android designed to run across many devices with different screen sizes and display resolutions. One of the things that confuse many new Android developers is how to support multiple screen sizes. For making SUSI Android app more user-friendly and interactive we used a lot of images in the form of drawable resources. Most of these drawables are in the form of PNG (Portable Network Graphic) and to support multiple screen size we have to include separate images of varied dimensions because we can’t scale PNG images without losing quality. Other disadvantages of using PNG images are PNG images take large disk space. PNG images have fixed colour and dimensions which cannot be changed. To overcome these shortcomings of PNG image we decided to use vector images in SUSI Android. Advantages of using vector image are It is smaller in size as compared to PNG i.e it takes less disk space than PNG. It can be scaled without losing quality. So we need to include only a single image for all screen size. Disadvantages of using vector image are Reconstruction of vector data may take considerably longer than that contained in a bitmap file of equivalent complexity because each image element must be drawn individually and in sequence. Vector image can’t be used to display complex photographs. If the object consists of a large number of small elements then file size grow very fast. Vector produce smaller size file than bitmap only for simple stuff. When it comes to creating a photographic quality vector where colour information is paramount and may vary on a pixel-by-pixel basis, the file can be much larger than its bitmap version, that’s why vector image is only suitable for small images like logo designs, icons etc. In this blog post, I will show you how we used vector images in SUSI Android. How to create vector image using Asset Studio tool Asset Studio is inbuilt Android Studio tool which we use to create a vector image from default material icon or local SVG images. To use vector asset in Android Studio Go to File> New > Vector Asset Vector Asset Studio Tool Window is prompted Create vector image from default material icon or local SVG image. Asset Studio will add icon in drawable. It can be used anywhere in the project. Vector images in SUSI Android In SUSI Android all drawable images like search, mic, arrow, check etc are vector images, even the logo of the app is a vector image. This vector image is the result of code you can find here. Now I will describe some special attributes used here fillColor: It defines the colour of the image. So the colour of your image depends on the colour you provide in fillColor. We used white color(#ffffff) as fillColor that’s why the image is white in colour. strokeColour: It defines the colour of boundary of the image. pathData: Shape of your image depends on pathData. Different commands used in pathData are M: It is used to define…
