70 likes | 224 Views
lec 07. Graphics Animations Location Services (GPS) Translating Location to Address Translating Address to Location. Graphics resources in Android. PNG (Portable Network Graphics) is a very versatile format among the raterized formats Make/search for PNGs with transparent backgrounds.
E N D
lec 07 • Graphics • Animations • Location Services (GPS) • Translating Location to Address • Translating Address to Location
Graphics resources in Android . PNG (Portable Network Graphics) is a very versatile format among the raterized formats Make/search for PNGs with transparent backgrounds. Raster versus Vector Vector will render perfectly every time and scales infinitely. If you need to use buttons with fancy borders, use 9patch. Good resource is http://openclipart.org/ From this you can get/create most any graphic element you need.
Use 9-Patch Steps to creating 9-patch image 1/ find a good png with a transparent background. 2/ open in image editor (Photoshop) and create at least a 1px tranparent margin along all sides. 3/ Issue the following command from command-line: draw9patch 4/ drag/open your png into this tool. 5/ Define registration marks; left and top define the scalable area, and the bottom and right define the content area.
Scaling images Android drawable directory structure. drawable is the default directory. drawable-mdpi (medium) is usually the corresponding directory with the same assets drawable-ldpi (low) drawable-hdpi (high) drawable-xhdpi (extra-high) Android's recommended percentages: 75%, 100%, 150%, 200% where medium is the baseline When scaling your images, find the highest possible resolution and scale like this: 37.5%, 50%, 75%, 100% where xhdpi is the baseline
Using Location Services in Android . You must generate a debug key. See video on how to do this. ~/content/lec07/22GenerateKey.webm Your key is dev-machine specific. If you're developing on a laptop and a desktop, you will need seperate keys for each. Window || Preferences || Android || Build to see where the key is stored. You don't have to, but it's easier if you externalize the key to a string.
Using Location Services in Android . Translate from place description e.g. 'Millennium park' to location. Translate from location to map Overlays: extends ItemizedOverlay<OverlayItem>
Context . In Android, Context is God. It give you direct access to application level calls such as startActivity and startService. Many components in Android indirectly extend the Context class, including Activity and Service, but you're better off accessing the ApplicationContext because it will never be null so long as the app is in memory. http://stackoverflow.com/questions/6854265/getapplicationcontext-getbasecontext-getapplication-getparent http://stackoverflow.com/questions/1026973/android-whats-the-difference-between-the-various-methods-to-get-a-context