title: Android Home Screen Widget (icon, label - style)
body: <p>I'm trying to create an icon/widget (1 cell x 1 cell) that can be placed on the home screen of android. The widget will look and act exactly like the other standard shortcuts in android. It will have an icon and under that a label, it will be selectable with the trackball (highlight able) it will be highlighted when it is selected/clicked.</p>
  
  <p>How do I go about creating this home screen widget?</p>
  
  <p>Do I have to create the widget myself using code/xml or is there some standard xml, style, theme, code that I can use to ensure that the widget will have the same style/theme as the other home screen widgets? </p>
  
  <p>I currently have the following</p>
  
  <p>res/drawable/corners.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;shape xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/Corners"&gt;
      &lt;stroke android:width="4dp" android:color="#CC222222"  /&gt;
      &lt;padding android:left="4dp" android:top="1dp" android:right="4dp" android:bottom="1dp" /&gt;
      &lt;corners android:radius="4dp" /&gt;
  &lt;/shape&gt;
  </code></pre>
  
  <p>res/layout/widget.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/Widget"
      android:layout_width="72dip"
      android:layout_height="72dip"
      android:orientation="vertical"
      android:focusable="true"
      android:gravity="center_horizontal"
      style="@android:style/Widget"   
      &gt;
  
      &lt;ImageView
          android:id="@+id/WidgetIcon"
          android:src="@drawable/icon"
          android:layout_width="fill_parent" 
          android:layout_height="50dip"
          android:paddingTop="3dip"
          android:gravity="center"
          /&gt;
  
      &lt;TextView
          android:id="@+id/WidgetLabel"
          android:layout_width="wrap_content"
          android:layout_height="fill_parent"
          android:text="@string/app_name"
          android:textSize="15dip"
          android:background="@drawable/corners"
          /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>The resulting widget looks some what close, but its not selectable, it doesn't get highlighted when clicked and the label isn't exactly in the correct location or the correct style.</p>
  
  <p>Any ideas, if there is a correct way to do this, or should I just keep working away on the above until I am closer?</p>