widget~~2--配置文件

有关AndroidManifest.xml中详细的recevier代码如下

1   < receiver android:name = " .ProtipWidget " android:label = " @string/widget_name " >
2             < intent - filter >
3                 < action android:name = " android.appwidget.action.APPWIDGET_UPDATE " />
4                 < action android:name = " com.android.protips.NEXT_TIP " />
5                 < action android:name = " com.android.protips.HEE_HEE " />
6             </ intent - filter >
7             < meta - data android:name = " android.appwidget.provider "
android:resource
= " @xml/widget_build " />
8         </ receiver >      

 

有关res/xml/widget_build.xml的代码如下

1   < appwidget - provider xmlns:android = " http://schemas.android.com/apk/res/android "
2     android:minWidth = " 294dip "
3     android:minHeight = " 72dip "
4     android:updatePeriodMillis = " 0 "
5     android:initialLayout = " @layout/widget " />      

 

 

有关res/layout/widget.xml的代码如下,注意下面使用了布局文件套嵌的include方式   

1 < RelativeLayout xmlns:android = " http://schemas.android.com/apk/res/android "
2     android:id = " @+id/widget "
3     android:layout_width = " fill_parent "
4     android:layout_height = " wrap_content "
5     android:orientation = " vertical "
6     android:padding = " 5dip "
7     >
8
9     < include layout = " @layout/droid " />
10     < include layout = " @layout/bubble " />
11   </ RelativeLayout >

 

 

有关res/layout/droid.xml的代码如下

1   < ImageView xmlns:android = " http://schemas.android.com/apk/res/android "
2     android:id = " @+id/bugdroid "
3     android:src = " @drawable/droidman_down_closed "
4     android:scaleType = " center "
5     android:layout_width = " wrap_content "
6     android:layout_height = " wrap_content "
7     android:layout_alignParentRight = " true "
8     android:layout_centerVertical = " true "
9     />
10

有关res/layout/bubble.xml的代码如下

1   < RelativeLayout xmlns:android = " http://schemas.android.com/apk/res/android "
2     android:id = " @+id/tip_bubble "
3     android:layout_width = " fill_parent "
4     android:layout_height = " wrap_content "
5     android:layout_toLeftOf = " @+id/bugdroid "
6     android:layout_centerVertical = " true "
7     android:gravity = " center_vertical|left "
8     android:layout_marginRight = " 2dip "
9     android:visibility = " invisible "
10     android:background = " @drawable/droid_widget "
11     android:focusable = " true "
12     >
13     < TextView
14         android:layout_width = " 0dip "
15         android:layout_height = " 0dip "
16         android:layout_alignParentTop = " true "
17         android:layout_marginTop = " -100dip "
18         android:text = " @string/widget_name "
19         />
20     < TextView
21         android:layout_width = " 0dip "
22         android:layout_height = " 0dip "
23         android:layout_alignParentTop = " true "
24         android:layout_marginTop = " -90dip "
25         android:text = " @string/tts_pause "
26         />
27     < TextView
28         android:id = " @+id/tip_footer "
29         style = " @style/TipText.Footer "
30         android:layout_width = " wrap_content "
31         android:layout_height = " wrap_content "
32         android:layout_alignParentBottom = " true "
33         android:layout_alignParentRight = " true "
34         android:layout_marginRight = " 1dip "
35         />
36     < ImageView
37         android:id = " @+id/tip_callout "
38         android:layout_width = " wrap_content "
39         android:layout_height = " fill_parent "
40         android:gravity = " center "
41         android:layout_alignParentTop = " true "
42         android:layout_alignParentRight = " true "
43         android:layout_above = " @id/tip_footer "
44         android:visibility = " gone "
45         android:padding = " 4dip "
46         />
47     < TextView
48         android:id = " @+id/tip_header "
49         style = " @style/TipText.Header "
50         android:layout_width = " fill_parent "
51         android:layout_height = " wrap_content "
52         android:layout_alignParentTop = " true "
53         android:layout_toLeftOf = " @id/tip_callout "
54         android:layout_alignWithParentIfMissing = " true "
55         android:layout_marginTop = " 0dip "
56         android:layout_marginLeft = " 3dip "
57         />
58     < TextView
59         android:id = " @+id/tip_message "
60         style = " @style/TipText.Message "
61         android:layout_width = " fill_parent "
62         android:layout_height = " wrap_content "
63         android:layout_below = " @id/tip_header "
64         android:layout_alignLeft = " @id/tip_header "
65         android:layout_alignRight = " @id/tip_header "
66         android:layout_marginTop = " 1dip "
67         />
68 </ RelativeLayout >

有关上面bubble.xml中的drawable对象droid_widget的代码如

1   < selector xmlns:android = " http://schemas.android.com/apk/res/android " >
2     < item android:state_pressed = " true " android:drawable = " @drawable/droid_widget_pressed " />
3     < item android:state_focused = " true " android:state_window_focused = " true " android:drawable = " @drawable/droid_widget_focused " />
4     < item android:state_focused = " true " android:state_window_focused = " false " android:drawable = " @drawable/droid_widget_normal " />
5     < item android:drawable = " @drawable/droid_widget_normal " />
6 </ selector >

 

你可能感兴趣的:(widget)