px Pixels – corresponds to actual pixels on the screen. pt Points – 1/72 of an inch based on the physical size of the screen. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and the user’s preference. (The compiler accepts both “dip” and “dp”, though “dp” is more consistent with “sp”.) sp Scale-independent Pixels – this is like the dp unit, but it is also scaled by the user’s font size preference. You should use these units when specifying view dimensions in your layout, so the UI properly scales to render at the same actual size on different screens. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. These units are relative to a 160 dpi (dots per inch) screen, so 160dp is always one inchregardless of the screen density. Dimensions dp Density-independent Pixels – an abstract unit that is based on the physical density of the screen. If you’re wondering which unit of measure to use. Referenced strings are stored in res/values/strings, referenced by “ and may be edited using the resource editor.I like to extract information shared by multiple UI elements like sizes, paddings, margins and the Android SDK makes this really easy. Create the directory res/drawable if it does not exist and put this image there. As you might have noticed I am using a special background image here – you may download it from the Android Developers Website (there are multiply default backgrounds of different sizes you may use) or directly here.Create a new project by doing New Project > News Android Project in Eclipse.A Service to respond to the events and to adjust the configuration to enable or disable the screen timeout.Several Intents and PendingIntents to handle the situations when the users clicks on “On”, “Off” or somewhere in the widget.A WidgetProvider to handle updates and events that our widget receives and triggers.To achieve this goal, we’re going to need the following components: The display should load and display the current setting for the screen timeout especially when it is loaded for the first time, the widget is updated or the user clicks somewhere in the widget (exception: “On/Off”).If the user clicks on the text “ Off” in the widget, the screen timeout will be disabled and the display updated.If the user clicks on the text “ On” in the widget, the screen timeout will be set to a pre-defined value and the widget will update its display to show this information.We’re going to implement a widget that is able to execute the following actions: I recommend using Eclipse with the ADT Plugin installed but it’s optional.An AVM with at least Android 2.2 / API Version 8.I am going to use Eclipse throughout the tutorial but you’re not forced to use Eclipse – I recommend it though :) The following software should be installed if you want to create the widget application by yourself.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |