Android Resources:
Android Application is Not all about source code, there are many other files to make an Android application. Apart from coding the application, we have various other files to care about, like some static content that our code use, such as Application Layout, it's color, some videos and audio files, animation and instruction, bitmaps and more. These are files are non-source code files and referred to as Resources and are compiled along with the source code to build an application.
Organize Resource in Visual Studio:
In Visual Studio, Application resources are organized according to their type into these subdirectories.
» Images files goes into the Drawable Directory.
» XML files that define a User Interface Layout goes into the Layout Directory.
» XML Files that contain Simple Values, such as String, integers and color goes into the Values directory.
These Resources are Known as Default Resources and are used by all devices unless a more specific match is specified.
Default Resources:
Default Resources are Items that are not specific to any particular device, therefore these resources are default choice by Android operating system if no more specific resources can be found. These resources are the most common type of resource to create and are organized into sub-directories of the Resources directory according to their resource type.
Below table provide the complete list of resources.
Resource type | Directory | Description |
---|---|---|
animator | Resources\animator\ | It's an XML file, that define property animations. The property animations are powerful and flexible way to describe animations. |
anim | Resources\anim\ | It's an XML fle that describe Tween animations. Tween animations are a series of animation instruction to perform transformations on the contents of a view object. |
color | Resources\color\ | It's an XML files that describe a state list of color. To Understand color state lists, consider a Button. It have different states such as pressed or disables. The button is blue, so it may change its color to red when user press it. |
drawable | Resources\drawable\ | In this directory, we can save image files of any type Or XML files that are compiled into bitmaps, state lists, shapes or animation drawable. |
layout | Resources\layout\ | It's an XML file that define a user interface layout. |
menu | Resources\menu\ | It's an XML file that define application menus, such as Option menu, context menu, or sub menu. |
raw | Resources\raw\ | These are Arbitrary files. these files are compiled into an android application in a binary format. |
values | Resources\values\ | It's an XML file that contain simple values, such as string, integers, color etc. |
xml | Resources\xml\ | These are Arbitrary XML files, and we read these files at runtime. We can save various configuration files here which will be used at run time. |
Alternative Resources:
Alternative Resources Provide support to specific device configuration. For Example, we should include alternative drawable resources like images for different screen resolution and alternative string resources for different language. At run time, Android detect the current device configuration and loads the appropriate resources for our application.
It is possible that An android Application will contain many resources. So, How Android will select the resources for an application when it runs on a device?
Take these following example to understand how Android Select the Resources.
» If the Device Orientation is Portrait, Then Android will ignore all Landscape resources directories.
» If a Resource directory contains a Qualifier that is not supported by the device, Android will ignore that resource directory.