Friday, August 1, 2014
Images
"Your PNG or JPEG bitmap image goes into its proper /res/drawable folder depending on its pixel dimensions. It can then be referenced by its file name only (excluding its extension) in the Java code, as well as in XML. For this important reason, be sure not to give a PNG file and a JPG file the same name, or you will have problems when it comes time to compile your code.
Also, contrary to normal file-naming conventions, image file names can contain only numbers, an underscore character, and lowercase letters, so make sure to remember this rule (one of the many anomalies of Android programming)."
The Values Folder
"The Values Folder
This is where you place predefined application values in the form of XML files that define the variable names (x or y, for instance) and their values that are later referenced in your Java code. Think of the values folder as holding all of your constant values for your application in one place. This way, if you need to adjust them during application development and testing, you make the changes in a single location.
colors.xml: An XML file that will define the color values to be used in the app. These allow you to standardize the UI. For example, you would define your background color. Then, if you decide to tweak it later, you need to do the tweaking in only one place.
dimens.xml: An XML file that defines dimension values, such as standard heights and font sizes for your UI. You can then use these values across your app to ensure it is consistent.
arrays.xml: An XML file that defines a series of values to be used together (known as an array). For example, this could be a list of icon files or a list of options to display to the user.
strings.xml: An XML file that defines text strings to be used in the application. For example, you can place any screen titles or the app’s name here and reference them in your code. If you need to change these items, you simply do it here rather than in your code.
styles.xml: An XML file that defines styles to be used in the application. These styles are then applied to the UI elements that require them, so you separate the look of your app from the layout and functionality. This makes your app easier to maintain."
Common Default Resources Folders
"Common Default Resources Folders
The following are the eight provided when you create a project in Eclipse:
layout: UIscreen layouts go in the /res/layout folder, which holds XML files containing UI layout definitions written in XML.
drawable-hdpi: high-resolution images in PNG format (which Google prefers) or the JPEG format (acceptable but not favored by Google) go into the /res/ drawable-hdpi (high resolution screen-drawable imagery, usually 800 by 480 pixels) folder.
drawable-ldpi: low-resolution images in PNG format (which Google prefers) or the JPEG format (acceptable but not favored by Google) go into the /res/drawable-ldpi (low resolution screen-drawable imagery, usually 320 by 240 pixels) folder.
drawable-mdpi: medium-resolution images in PNG format (which Google prefers) or the JPEG format (acceptable but not favored by Google) go into the /res/drawable-mdpi (medium resolution screen-drawable imagery, usually 480 by 320 pixels) folder.
drawable-xhdpi: extra-high-resolution images in PNG format (which Google prefers) or the JPEG format (acceptable but not favored by Google) go into the /res/drawable-xhdpi (high resolution screen-drawable imagery, usually 1,280 by 720 pixelsor HD) folder
values: XML files that define constant values are in the res/values folder.
values-v11: honeycomb theme XML files that define new UItheme values are in the res/values-v11 (referencing API Level 11 through 13, also known as Android 3.x or 3.0, 3.1, and 3.2) folder.
values-v14: Ice Cream Sandwich theme XML files that define new UItheme values are in the res/values-v14 (referencing API Level 14 through 16, also known as Android 4.x or 4.0, 4.0.3, and 4.1) folder.
menu: XML files defining menu layouts are in the res/menu folder."
The DVM
"When you launch an Android application, it creates a process that allocates memory and CPU processing resources (processor time slices) to the application, so that it has the resources needed to function. Each time an application is launched and a process is spawned, an instance or copy of the DVM is launched into your Android smartphone, iTV, or tablet’s memory. The DVM actually takes the Java language instructions along with the application’s design guidelines (in an XML format), and combines them with any external resources (images, audio or video files, 3D, and so on), and translates them all into optimized low-level binary code that goes into the Android device’s memory and eventually into the processor for processing."
Subscribe to:
Comments (Atom)