Widget配置文件学习应用是本文要介绍的内容,主要是来了解并学习Widget配置文件,具体内容的实现来看详细代码。
有关AndroidManifest.xml中详细的recevier代码如下
<receiver android:name=".ProtipWidget" android:label="@string/widget_name">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="com.android.protips.NEXT_TIP" />
<action android:name="com.android.protips.HEE_HEE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
roid:resource="@xml/widget_build" />
</receiver>
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
有关res/xml/widget_build.xml的代码如下
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="294dip"
android:minHeight="72dip"
android:updatePeriodMillis="0"
android:initialLayout="@layout/widget" />
- 1.
- 2.
- 3.
- 4.
- 5.
有关res/layout/widget.xml的代码如下,注意下面使用了布局文件套嵌的include方式
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dip"
>
<include layout="@layout/droid" />
<include layout="@layout/bubble" />
</RelativeLayout>
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
有关res/layout/droid.xml的代码如下
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/bugdroid"
android:src="@drawable/droidman_down_closed"
android:scaleType="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
/>
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
有关res/layout/bubble.xml的代码如下
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tip_bubble"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/bugdroid"
android:layout_centerVertical="true"
android:gravity="center_vertical|left"
android:layout_marginRight="2dip"
android:visibility="invisible"
android:background="@drawable/droid_widget"
android:focusable="true"
>
<TextView
android:layout_width="0dip"
android:layout_height="0dip"
android:layout_alignParentTop="true"
android:layout_marginTop="-100dip"
android:text="@string/widget_name"
/>
<TextView
android:layout_width="0dip"
android:layout_height="0dip"
android:layout_alignParentTop="true"
android:layout_marginTop="-90dip"
android:text="@string/tts_pause"
/>
<TextView
android:id="@+id/tip_footer"
style="@style/TipText.Footer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginRight="1dip"
/>
<ImageView
android:id="@+id/tip_callout"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_above="@id/tip_footer"
android:visibility="gone"
android:padding="4dip"
/>
<TextView
android:id="@+id/tip_header"
style="@style/TipText.Header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@id/tip_callout"
android:layout_alignWithParentIfMissing="true"
android:layout_marginTop="0dip"
android:layout_marginLeft="3dip"
/>
<TextView
android:id="@+id/tip_message"
style="@style/TipText.Message"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tip_header"
android:layout_alignLeft="@id/tip_header"
android:layout_alignRight="@id/tip_header"
android:layout_marginTop="1dip"
/>
elativeLayout>
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
- 51.
- 52.
- 53.
- 54.
- 55.
- 56.
- 57.
- 58.
- 59.
- 60.
- 61.
- 62.
- 63.
- 64.
- 65.
- 66.
- 67.
- 68.
有关上面bubble.xml中的drawable对象droid_widget的代码如
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/droid_widget_pressed" />
<item android:state_focused="true" android:state_window_focused="true" android:drawable="@drawable/droid_widget_focused" />
<item android:state_focused="true" android:state_window_focused="false" android:drawable="@drawable/droid_widget_normal" />
<item android:drawable="@drawable/droid_widget_normal" />
selector>
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
小结:解析关于Widget配置文件学习应用的内容介绍完了,希望通过Widget配置文件内容的学习能对你有所帮助!