Android widget WRAP_CONTENT not working
<p>I have following widget in my app and it contains an <code>ImageView</code> with width and height set as <code>WRAP_CONTENT</code>. Root view is a <code>RelativeLayout</code> again with width and height set as <code>WRAP_CONTENT</code>.</p>

<p><a href="https://i.stack.imgur.com/HzSif.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HzSif.jpg" alt="enter image description here"></a></p>

<p>My issue is why there are some padding (marked in black) on top and bottom of the widget? I want it to be perfectly square. Following is my widget layout.</p>

<pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/widget_battery_2x2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="#000000"
    android:layout_margin="@dimen/widget_margin"
    android:padding="@dimen/widget_padding" &gt;

    &lt;ImageView
        android:id="@+id/image_widget_arc_battery"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#ff0000"
        android:layout_alignParentLeft="true"/&gt;
&lt;/RelativeLayout&gt;
</code></pre>

<p><code>@dimen/widget_margin</code> and <code>@dimen/widget_padding</code> is zero.</p>

<p><code>ImageView</code> contains a dynamically generated Bitmap (width and height is 400).</p>

<pre><code>Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
</code></pre>

<p>This is my first widget app :) I'm kinda lost and can not figure out why this extra padding is there. Anybody has an idea?</p>

<p>Thanks for your help.</p>