解析關(guān)于Widget配置文件學(xué)習(xí)應(yīng)用
Widget配置文件學(xué)習(xí)應(yīng)用是本文要介紹的內(nèi)容,主要是來(lái)了解并學(xué)習(xí)Widget配置文件,具體內(nèi)容的實(shí)現(xiàn)來(lái)看詳細(xì)代碼。
有關(guān)AndroidManifest.xml中詳細(xì)的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>
 
有關(guān)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" />
 
有關(guān)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>
 
有關(guān)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"
 - />
 
有關(guān)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>
 
有關(guān)上面bubble.xml中的drawable對(duì)象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>
 
小結(jié):解析關(guān)于Widget配置文件學(xué)習(xí)應(yīng)用的內(nèi)容介紹完了,希望通過(guò)Widget配置文件內(nèi)容的學(xué)習(xí)能對(duì)你有所幫助!















 
 
 
 
 
 
 