This repository has been archived by the owner on Jan 10, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 86
App Components (HowTo)
Sebastian Stein edited this page Aug 18, 2017
·
1 revision
TODO
We are using Widgets as they are defined in googles documentation: developer.android.com/guide/topics/appwidgets
more information
Java | |
---|---|
.../widgets/<title>Widget.jav a |
Manages the lifecycle of the widget and updates the content. |
.../widgets/<title>WidgetConfigureActivity.java |
If the widget needs any configuration this Activity is used. It can be opened whenever a new widget is created or via an intend(optional) |
.../widgets/<title>WidgetService.java |
Manages the collection view items in a adapter like manner (optional). |
Res | |
.../drawable/widget_<title>_preview.png |
Preview image of the widget, is shown when the user wants to add a widget to the homescreen. |
.../layout/<title>_widget.xml |
The main layout of the widget, you can only use items here, that work with widgets. |
.../layout/activity_<title>_widget_configuration.xml |
The layout of the widget configuration activity (optional). |
.../layout/<title>_widget_item.xml |
If you are using a collection view, the item layout is defined here (optional) |
.../xml/<title>_widget_info.xml |
The configuration file of the widget (See widget configuration). |
- Layouts:
FrameLayout
,LinearLayout
andRelativeLayout
. - Views:
AnalogClock
,Button
,Chromometer
,ImageButton
,ImageView
,ProgressBar
andTextView
. - Adapter Views:
GridView
,ListView
,StackView
,ViewFlipper
andAdapterViewFlipper
(These require a collection view widget).
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:initialKeyguardLayout="@layout/timetable_widget"
android:initialLayout="@layout/timetable_widget"
android:minHeight="110dp"
android:minResizeHeight="60dp"
android:minResizeWidth="220dp"
android:minWidth="250dp"
android:previewImage="@drawable/widget_timetable_preview"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="15000"
android:widgetCategory="home_screen|keyguard"
tools:targetApi="jelly_bean_mr1" />
-
android:initialLayout
: The main layout file of the widget -
android:previewImage
: The preview image of the widget -
android:widgetCategory
: Where this widget can be used, eg. homescreen and keyguard (=lockscreen) -
android:resizeMode
: In which directions the widget can be resized -
android:min(Resize)Width/Height
: The size boundaries of the widget -
android:updatePeriodMillis
: How often the system should refresh the data on the widget in ms (this wakes the device, so if you have to update more then every hour user androids alarm functionalities)