Android Learning note: Home screen Widgets (1): about widget

Source: Internet
Author: User
Tags home screen
<span id="Label3"></p><span style="color:rgb(192,80,77)"><span style="color:rgb(192,80,77)">What is home screen Widgets</span></span><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">The home screen widget, called a gadget or a Chinese gadget, is a view that is displayed on the home page and updates the views data through the background process.</p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">Android is managed by Appwidgetmanager to manage the widgets of the System. After installing the APK. The Widget's name, icon, and occupied space are displayed in the widget list according to the widget definition in Android4.0. In a grid way, some OEMs will design the UI again, and the widget list will be presented in a different form.</p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">We long press one of the widgets in the widget List. Drag it to the home page. Appwidgetmanager is actually creating an instance of the widget on the home page (instance).</p></p><p><p>can have multiple instances, and different instances use Widgetid to differentiate Them.</p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">The widget defines two important Java classes, one of which is the widget configurator Activity. When the widget instance is generated, it is initialized by Appwidgetmanager through intent, with the action named android.appwidget.action.APPWIDGET_CONFIGURE, This Java class is optional and is typically used to enter and save configuration Data. Because the amount of data is Small. It is very easy to save in a shared preference.</p></p><p><p>Let's say We've created two widget instances, and this configuration activity will be called two Times.</p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">A Java class. Manages the lifecycle of the widget, including when it needs to be updated when dragged to the homepage, and when it is dragged into the garbage bin. It is the inheritance of appwidgetprovider, essentially a broadcast receiver, based on the broadcast information issued by Appwidgetmanager. Triggers different callback functions, such as the widget data update interval (given in the widget definition), and the generation and deletion of widget Instances. The generation of the first widget Instance. Deletion of the last widget Instance.</p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">The Widget's build on the page is generated by Appwidgetmanager based on the layout file we gave in the widget Definition. It is not generated directly by our code, so we are not able to manipulate the view in the widget directly in the activity, and need to pass the Remoteviews. Submit to Appwidgetmanager to process an instance.</p></p><p><p></p></p><span style="color:rgb(192,80,77)">sample <span style="color:rgb(192,80,77)">Samples</span></span><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">We will pass the Sample. Explain how to create a widget. The sample is a birthday reminder.</p></p><p><p></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">When the widget instance is generated, the activity is popped up and the name and date of birth are entered in the Activity. Press the Set button to save the data in preference and close the Activity.</p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">The Widget's top view shows Widget_id: first name, and the middle left shows the number of days from the next birthday. Click the view on the right to open a webpage, and the date of birth is shown below.</p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><br></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><span style="color:rgb(192,80,77)"><strong>Defining a broadcast sink</strong></span></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">As mentioned earlier, the widget has two important Java classes, an optional activity for configuration, a broadcast receiver for managing the Wdiget life cycle, and a receiver receiving Appwidgetmanager broadcast Messages. To trigger various callback Functions.</p></p><p><p>We need to define these two Java classes in androidmanifest.xml, and the following gives the class definition of the broadcast Receiver.</p></p><p style="margin:0px 10pt; padding:5pt; font-family:微软雅黑; font-size:10pt; border:thin solid rgb(79,98,40); line-height:18.6666660308838px; background-color:rgb(248,248,248)"><span style="color:rgb(102,102,102)"><span style="color:rgb(102,102,102)"><manifest. ><br><application ... <span style="color:rgb(0,0,0)">android:label= "testwidget"</span> ......> <span style="color:rgb(0,128,255)"><!--android:label is the widget name in the widget list--</span><br>...</span></span><br><<strong><strong>receiver</strong></strong>Android:name= ". Birthdaywidgetprovider "><br><strong><strong><meta-data android:name= "android.appwidget.provider" android:resource= "@xml/birthday_widget_provider"/ ><br></strong></strong><<strong><strong>intent-filter><br><action android:name= "android.appwidget.action.APPWIDGET_UPDATE"/><br></intent-filter></strong></strong><br></receiver><br><span style="color:rgb(102,102,102)"><span style="color:rgb(102,102,102)"></application><br></manifest></span></span></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">This class is inherited from the android.appwidget.AppWidgetProvider, and is set by the Meta-data about the number of References.</p></p><p><p></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><span style="color:rgb(102,102,102)">Here to add Meta-data knowledge. The most common is the use of Key-value pairs, that is, <meta-data android:name= "xxx" android:value= "yyy"/>, in the component can obtain this value, such as in the Activity:</span></p></p><p style="margin:0px 10pt; padding:5pt; font-family:微软雅黑; font-size:10pt; border:thin solid rgb(79,98,40); line-height:18.6666660308838px; background-color:rgb(248,248,248)"><p style="margin:0px 10pt; padding:5pt; font-family:微软雅黑; font-size:10pt; border:thin solid rgb(79,98,40); line-height:18.6666660308838px; background-color:rgb(248,248,248)"><span style="color:rgb(102,102,102)">Activityinfo actinfo = Mcontext.getpackagemanager (). getactivityinfo (getcomponentname (), PackageManager.GET_META_ DATA);<br>String msg = actInfo.metaData.getString ("activity_name");<br></span></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><span style="color:rgb(102,102,102)">In the service, it is serviceinfo, which is applicationinfo in Application. In receiver for activityinfo, but with getreceiverinfo, assuming componentname parameters, can be used with new componentname (context, Mycomponent.class) To Get.</span></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">Let's look at the code for Android.appwidget.AppWidgetManager.java:</p></p><p style="margin:0px 10pt; padding:5pt; font-family:微软雅黑; font-size:10pt; border:thin solid rgb(79,98,40); line-height:18.6666660308838px; background-color:rgb(248,248,248)"><span style="font-family:‘Courier New‘"><span style="color:rgb(100,107,134)"><span style="color:rgb(100,107,134)">/**<br>* Sent when it was time to update your appwidget.<br>*<br>* This is <strong>sent in response to a new instance for this Appwidget provider have<br>* Been instantiated</strong>, the requested {@link Appwidgetproviderinfo#updateperiodmillis update interval} having lapsed, o R the System Booting.<br>* ......<br>*<br>* @see appwidgetprovider#onupdate appwidgetprovider.onupdate (context context, appwidgetmanager appwidgetmanager, int[ ] Appwidgetids)<br>*/</span></span><br>public static final String action_appwidget_update = "<strong><strong>Android.appwidget.action.APPWIDGET_UPDATE</strong></strong>";<br><br><span style="color:rgb(100,107,134)"><span style="color:rgb(100,107,134)">/**<br>* Field for the manifest meta-data tag.<br>*<br>* @see Appwidgetproviderinfo<br>*/</span></span><br>public static final String Meta_data_appwidget_provider = "<strong><strong>Android.appwidget.provider</strong></strong>";</span></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">In meta-data, android.appwidget.provider is the keyword specified for android. The file used to define the app Widget provider information in the appropriate resource. The file is located under xml/. This example is res/xml/birthday_widget_provider.xml, which defines the widget's number of References.</p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">Android.appwdiget.action.APPWIDGET_UPDATE is one of the receivers listening to Appwidgetmanger broadcast Messages. The other also listens to action_appwidget_enabled and so on News. however, in receiver it must be indicated that the action_appwidget_update, the system can recognize the receiver is actually a widget, the ability to add the widget in the widget List. Other messages that need to be monitored need not be listed Here.</p></p><span style="color:rgb(192,80,77)"><span style="color:rgb(192,80,77)">definition of App widget provider</span></span><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">In the Manifest.xml. The appwidget provider defined by Meta-data is xml/birthday_width_provider.xml, the contents of which are as Follows.</p></p><p><p></p></p><p style="margin:0px 10pt; padding:5pt; font-family:微软雅黑; font-size:10pt; border:thin solid rgb(79,98,40); line-height:18.6666660308838px; background-color:rgb(248,248,248)"><p style="margin:0px 10pt; padding:5pt; font-family:微软雅黑; font-size:10pt; border:thin solid rgb(79,98,40); line-height:18.6666660308838px; background-color:rgb(248,248,248)"><span style="color:rgb(165,165,165)"><?</span></p></p><p><p>XML version= "1.0" encoding= "utf-8"?</p></p><p><p>><br><<strong>appwidget-provider</strong> <span style="color:rgb(102,102,102)">xmlns:android= "http://schemas.android.com/apk/res/android"<br></span><strong>android:minwidth</strong>= "150dp"<br><strong>android:minheight</strong>= "120dp"<br><strong>Android:updateperiodmillis</strong>= "43200000"<br><strong>android:initiallayout</strong>= "@layout/birday_widget"<br><strong>android:configure</strong>= "cn.wei.flowingflying.testwidget.ConfigBirthDayWidgetActivity"<br><strong>android:previewimage</strong>= "@drawable/gift"<br>Android:resizemode= "horizontal|vertical" ><br><strong></appwidget-provider></strong></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">In the widget list, the widget size is 3x2.</p></p><p><p>In the Xml. We define a length of 150dp, a width of 120dp, and the actual widget occupied by the home screen is calculated by Grid. Each grid is 74dpx74dp, and the system assigns the desired grid to Fit. The general cell phone grid is 4x4 and the tablet is 8x7.</p></p><p><p>In Pro Android, the recommended 74 N times minus 2DP (fit Border) is recommended, whereas at the Android developer site The min length width defined is 70*n-30. The following is a sample given:</p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">This example has a time interval of 12 hours (43200000ms).</p></p><p><p>Android strongly recommends 1 days at most only a few times, not too much.</p></p><p><p>Starting from Android2.0, the minimum value is 30 minutes.</p></p><p><p><strong>Let's say we set it to 0. Indicates that we are not actively update, and we are able to control when update by Alarmmanager class.</strong></p></p><p><p>As an experimental sample. Can be changed to 1 hours, but can not be set too short, such as 1 minutes, in the simulator experiment, assuming that the time interval is too short is not triggered.</p></p><p><p></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">Start from SDK3.1. The widget can be resize by the user by long pressing the Widget. Contains Horizontal,vertical and NONE. To be able to resize, require that the layout parameters be scalable, Note. Suppose the size change is not callback Alert.</p></p><p><p>Details how resize not quite understand.</p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">Previewimage is the icon in the widget list, assuming that there is no such item, the main icon defined in the manifest file is Useful. The display in the widget list is also called PREVIEW.<br></p></p><span style="color:rgb(192,80,77)"><span style="color:rgb(192,80,77)">Configure the definition of activity</span></span><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">Java class configbirthdaywidgetactivity, which is defined by Android:configure in appwidget-provider, is an ordinary activity, It needs to be explained in Androidmanifest.xml and supports responding to Appwidget_configure Action. The code snippet for Androidmanifest.xml is as Follows:</p></p><p style="margin:0px 10pt; padding:5pt; font-family:微软雅黑; font-size:10pt; border:thin solid rgb(79,98,40); line-height:18.6666660308838px; background-color:rgb(248,248,248)"><p style="margin:0px 10pt; padding:5pt; font-family:微软雅黑; font-size:10pt; border:thin solid rgb(79,98,40); line-height:18.6666660308838px; background-color:rgb(248,248,248)"><activity android:name= ". Configbirthdaywidgetactivity "android:label=" configuration Birthday gadget ><br><intent-filter><br><strong><action android:name= "android.appwidget.action.APPWIDGET_CONFIGURE"/></strong><br></intent-filter><br></activity><br></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">So far. We're finished with the widget Definition. Even if we don't write the Java class code in detail, we can still package it and install it on the Device. After installation, see our sample Testwidget in the widget List.</p></p><p><p></p></p><span style="color:rgb(192,80,77)"><span style="color:rgb(192,80,77)">the Widget's appearance definition</span></span><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">Define the appearance of the widget in Appwidget-provider by Android:initiallayout. The corresponding layout/birday_widget.xml such as the Following:</p></p><p style="margin:0px 10pt; padding:5pt; font-family:微软雅黑; font-size:10pt; border:thin solid rgb(79,98,40); line-height:18.6666660308838px; background-color:rgb(248,248,248)"><?xml version= "1.0" encoding= "utf-8"?><br><linearlayout xmlns:android= "http://schemas.android.com/apk/res/android"<br><strong><strong>android:layout_width= "150dp"<br>android:layout_height= "120dp"<br></strong></strong>android:orientation= "vertical"<br>android:background= "@drawable/box1" ><br><textview android:id= "@+id/bd_name"<br>Android:layout_width= "match_parent"<br>android:layout_height= "30dp"<br>android:text= "Anonymous"<br>Android:background= "@drawable/box1"<br>android:gravity= "center"/><br><span style="color:rgb(102,102,102)"><span style="color:rgb(102,102,102)"><linearlayout android:orientation= "horizontal"<br>Android:layout_width= "match_parent"<br>android:layout_height= "60dp" ></span></span><br><textview android:id= "@+id/bd_days"<br>Android:layout_width= "wrap_content"<br>android:layout_height= "match_parent"<br>android:text= "0"<br>android:gravity= "center"<br>Android:textsize= "30sp"<br>android:layout_weight= "/>"<br><textview android:id= "@+id/bd_buy"<br>Android:layout_width= "wrap_content"<br>android:layout_height= "match_parent"<br>Android:textsize= "20sp"<br>android:text= "Buy"<br>android:layout_weight= "50"<br>Android:background= "#FF6633"<br>android:gravity= "center"/><br><span style="color:rgb(102,102,102)"><span style="color:rgb(102,102,102)"></LinearLayout><br></span></span><textview android:id= "@+id/bd_date"<br>Android:layout_width= "match_parent"<br>android:layout_height= "30dp"<br>android:text= "2000/1/1"<br>Android:background= "@drawable/box1"<br>android:gravity= "center"/> "<br></LinearLayout></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">Different from the Activity. You cannot get the object of a view directly in your code and control it. Indirect control is required through Appwidgetmanager with Remoteviews.</p></p><p><p>therefore, in the widget appearance definition, view needs to support remote view, including framelayout, linearlayout, relativelayout, analogclock, Button, chronometer, ImageButton, ImageView, ProgressBar, TextView, viewflipper, ListView, GridView, stackview, adapterviewflipper.</p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">Android gives widget design guideline, see Http://developer.android.com/guide/practices/ui_guidelines/widget_design.html.<br></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px">By android:background= "@drawable/box1", the perimeter contour can be defined.</p></p><p><p>The contents of the Res/drawable/box1.xml are as Follows:</p></p><p style="margin:0px 10pt; padding:5pt; font-family:微软雅黑; font-size:10pt; border:thin solid rgb(79,98,40); line-height:18.6666660308838px; background-color:rgb(248,248,248)"><p style="margin:0px 10pt; padding:5pt; font-family:微软雅黑; font-size:10pt; border:thin solid rgb(79,98,40); line-height:18.6666660308838px; background-color:rgb(248,248,248)"><?xml version= "1.0" encoding= "utf-8"?</p></p><p><p>><br><shape xmlns:android= "http://schemas.android.com/apk/res/android" ><br><<strong>stroke</strong> android:width= "4dp" android:color= "#888888"/> <span style="color:rgb(79,129,189)"><!--define borders--<br></span><<strong>padding</strong> android:left= "2dp" android:top= "2dp" android:right= "2dp" android:bottom= "2dp"/><br><<strong>Corners</strong> android:radius= "4dp"/><br></shape></p></p><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"><p style="margin-top:0px; margin-bottom:0px; padding-top:5pt; padding-bottom:5pt; font-family:微软雅黑; font-size:17px; line-height:23.3333320617676px"></p></p><br> <p style="font-size:12px;"><p style="font-size:12px;">Copyright Notice: This article blog original articles, blogs, without consent, may not be reproduced.</p></p> <p><p>Android Learning note: Home screen Widgets (1): about widget</p></p></span>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.