解析关于Widget配置文件学习应用

移动开发
Widget配置文件学习应用是本文要介绍的内容,主要是来了解并学习Widget配置文件,具体内容的实现来看详细代码。

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配置文件内容的学习能对你有所帮助!

责任编辑:zhaolei 来源: 博客园
相关推荐

2011-09-08 15:40:45

Android Wid组件

2010-03-18 18:17:01

Python 配置文件

2011-09-09 17:59:26

QT Widget

2011-03-28 09:07:26

Nagios配置文件

2011-09-09 11:05:56

Widget

2011-09-09 19:23:52

Widget

2010-02-22 10:18:18

WCF配置文件

2021-07-05 12:09:58

Python编程语言

2022-11-10 09:05:18

Lua配置文件

2011-09-07 13:42:36

Android Wid实例

2010-05-23 10:11:01

Widget开发

2009-11-17 16:46:01

PHP配置文件

2021-07-13 05:47:40

GroovyJSON软件开发

2011-09-07 16:28:46

QT WidgetQWidget

2011-09-07 16:36:00

Qt Widget

2011-09-07 14:25:53

Android Wid设计

2009-12-21 11:19:50

WCF配置文件

2010-02-03 09:19:31

Python模块

2009-11-27 08:59:29

VS2003配置文件

2021-08-13 13:55:03

鸿蒙HarmonyOS应用
点赞
收藏

51CTO技术栈公众号