Presentation is loading. Please wait.

Presentation is loading. Please wait.

Android Widget Tutorial

Similar presentations


Presentation on theme: "Android Widget Tutorial"— Presentation transcript:

1 Android Widget Tutorial
Martha Garcia

2 What is a widget? A broadcast receiver which provides interactive components that can be embedded in another application (like the homescreen) Allow users to view or control an app without actually launching it Can be updated automatically (after a time period), or in response to user action

3 How to Create a Widget Creating a widget requires four steps:
Design the widget layout Extend AppWidgetProvider provides methods that are called during a widget lifecycle Create an XML file properties of the widget, e.g. minimum width and height, update frequency… Enter the Widget configuration in the AndroidManifest.xml file

4 Design the Widget layout
Widgets are restricted in the View classes it can use Layouts: FrameLayout, LinearLayout, RelativeLayout Views: AnalogClock, Button, Chromometer, ImageButton, ImageView, ProgressBar, TextView, ViewFlipper, ListView, GridView, StackView and AdapterViewFlipper

5

6 res/values-v14/dimens.xml res/values/dimens.xml
Define the 0dp of padding that should be added to the margins that Android 4.0 creates by default. res/values/dimens.xml Define your widget’s custom margins that should be used on devices running anything earlier than Android 4.0

7 Extend AppWidgetProvider
Extend AppWidgetProvider, by creating the class SimpleWidgetProvider

8 Create an XML file Create simple_widget_info.xml and saved in the res/xml folder

9 AndroidManifest.xml file
Change the receiver android:name and meta-data android:resource

10

11 References widgets


Download ppt "Android Widget Tutorial"

Similar presentations


Ads by Google