Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In my <strong>4x1 widget</strong>, I used these dimensions for <strong>res/values/dimens.xml</strong>:</p> <pre><code>&lt;!-- size = (74 x n) - 2 --&gt; &lt;dimen name="appwidget_margin"&gt;0dp&lt;/dimen&gt; &lt;dimen name="appwidget_min_width"&gt;294dp&lt;/dimen&gt; &lt;dimen name="appwidget_min_height"&gt;72dp&lt;/dimen&gt; </code></pre> <p>and for <strong>res/values-v14/dimens.xml</strong>:</p> <pre><code>&lt;!-- size = (70 x n) - 30 --&gt; &lt;dimen name="appwidget_margin"&gt;0dp&lt;/dimen&gt; &lt;dimen name="appwidget_min_width"&gt;250dp&lt;/dimen&gt; &lt;dimen name="appwidget_min_height"&gt;40dp&lt;/dimen&gt; </code></pre> <p><strong>I used <a href="http://developer.android.com/guide/practices/ui_guidelines/widget_design.html#templates" rel="noreferrer">widget templates pack</a> for background images .</strong></p> <p>In <a href="http://developer.android.com/guide/topics/appwidgets/index.html#AddingMargins" rel="noreferrer">official guide</a> there is written that default margin in res/values/dimens.xml should be 8dp, but if I use 8dp, my widget is smaller than standard widgets on the desktop (google search, weather etc.). Thats's because margin for v1-v13 is built in the background image: </p> <p><img src="https://i.stack.imgur.com/ULHKE.png" alt="enter image description here"></p> <p>I tested it on HTC Desire, Nexus S, emulator Android 2.2 and emulator Android 2.3.3. With the templates pack backgrounds and configuration above, my widget's size is the same as other standard widgets and looks good on all devices I tested.</p> <p>There is also problem with various launchers. I recommend this article to read: <a href="http://radleymarx.com/blog/app-widget-padding-margins-in-ics-android/" rel="noreferrer">http://radleymarx.com/blog/app-widget-padding-margins-in-ics-android/</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload