keywords:
Bookmark and Share



Front Back
Resource file rules
- Filenames must be lowercase - Filenames can only contain letters, underscores, numbers and periods only - Filenames (and XML name attributes) must be unique
Accessing resources programmatically
R.java.resource_name E.g. - String greeting = getResources().getString(R.string.hello);
Accessing resources through a layout file
@[resource type]/[resource name] E.g. - @string/hello
Accessing system resources
For accessing resources that Android contains natively. Programmatically E.g. - String confirm = Resources.getSystem().getString(android.R.string.ok); Layout file E.g. - @android:string/ok
XML Resource Value Storage
Simple resources such as string, color and dimension values should be defined in XML files under the /res/values project directory in XML files.
XML < string > Resource Value *Ignore spacing between brackets*
< string > - for tagging string resources E.g. - < string name=\"hello\" >Hello< /string >
XML < color > Resource Value *Ignore spacing between brackets*
< color > - for using color resources E.g. - < color name=\"background_color\" >#006400< /color > Color Formatd Supported #RGB - 12-bit color #ARGB - 12-bit color with alpha #RRGGBB - 24-bit color #AARRGGBB - 24-bit color with alpha
XML < dimen > Resource Value
< dimen > - used for specifying the size of a UI control such as a Button or a TextView control.

E.g. - < dimen name="thumbDim" >100px< /dimen >

Types of Measurement
pixels - actual screen pixels - px
inches - physical measurement - in
millimeters - physical measurement - mm
points - common font measurement - pt
density-independent pixels - pixels relative to 160dpi - dp, dip
scale-independent pixels - best for scalable font display - sp
x of y cards