title: Widget margins not applied on ICS phone with TouchWiz launcher?
body: <p>I have an app with a widget. I know that Android 4.0 or later will automatically create a margin around the widget so I've implemented the suggestion on <a href="http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout" rel="nofollow noreferrer">this developers API page</a> to make the widgets approximately the same size on different Android versions. I've tested the widget in the emulator on API 10, 14 and 15 and it works fine. The widget looks the same in all versions. However, when I test it on my SGS2 phone with Android 4.0.3 there are no margins! How can this be? What am I missing? Did anyone else experience this behaviour?</p>
  
  <p><img src="https://i.stack.imgur.com/F9z1r.png" alt="Widget on emulator API 15">!<img src="https://i.stack.imgur.com/GbuDI.png" alt="enter image description here"></p>
  
  <p>Here's my <strong>res/xml/widget_info.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" 
  
      android:initialLayout="@layout/widget"    
      android:minHeight="40dp"  
      android:minWidth="110dp"
      android:updatePeriodMillis="60000" &gt;
  
  &lt;/appwidget-provider&gt;
  </code></pre>
  
  <p><strong>res/layout/widget.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/widget_mainlayout"
      android:layout_width="match_parent"
      android:layout_height="match_parent" 
      android:layout_margin="@dimen/widget_margin"
      android:background="@drawable/widget_background" &gt;             
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>res/drawable/widget_background.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;shape xmlns:android="http://schemas.android.com/apk/res/android"
      android:shape="rectangle" &gt;
  
  &lt;stroke
      android:width="2dp"
      android:color="#222222" /&gt;
  
  &lt;gradient
      android:angle="225"
      android:startColor="#DD2ECCFA"
      android:endColor="#DD000000" /&gt;
  
  &lt;corners android:radius="7dp" /&gt;
  
  &lt;/shape&gt;
  </code></pre>
  
  <p><strong>res/values/dimens.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
      &lt;dimen name="widget_margin"&gt;8dp&lt;/dimen&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p><strong>res/values-v14/dimens.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
      &lt;dimen name="widget_margin"&gt;0dp&lt;/dimen&gt;  
  &lt;/resources&gt;
  </code></pre>
  
  <p>At first I thought it had something to do with the widget not being properly updated as described <a href="https://stackoverflow.com/q/6014015/741249">here</a>, but removing the widget and adding it again doesn't help. I've also experimented a bit with the settings:</p>
  
  <ul>
  <li>Setting <code>maxHeight</code> and <code>maxWidth</code> in the <code>widget_info.xml</code> file doesn't work, it seems to be ignored by both the emulator and the phone. </li>
  <li>Changing <code>layout_margin</code> to <code>padding</code> in the <code>widget.xml</code> file has no effect, widget looks the same (but on emulator API10 widget now also has no margins)</li>
  <li>Changing the <code>0dp</code> to <code>16dp</code> in the <code>res/values-v14/dimens.xml</code> file does have an effect in both the phone and the emulator, but the widget's size on the phone and emulator still is different.</li>
  </ul>
  
  <p><strong>EDIT:</strong>
  I've installed GO Launcher Ex on the phone and then the widget does have margins, so I guess this is a specific issue for Samsung's TouchWiz launcher? Can anyone confirm this? I am also interested in solutions to make the widget look (more or less) the same when using TouchWiz.</p>