title: Remove padding of ImageButton
body: <p>How can I get an <code>ImageButton</code> that has a fixed height and is only as wide as it needs according to the ratio of its source image?</p>
  
  <p>I tried the following:</p>
  
  <pre><code>&lt;ImageButton
      android:layout_width="wrap_content"
      android:layout_height="8pt"
      android:minWidth="0pt"
      android:scaleType="fitCenter"
      android:adjustViewBounds="true"
      android:src="@drawable/list_download"
      android:background="@android:color/black"
      android:padding="0pt"/&gt;
  </code></pre>
  
  <p>I set background to black just to see the boundaries of it exactly, and <a href="https://i.stack.imgur.com/jyDcx.png" rel="nofollow noreferrer">here</a> is the outcome.</p>
  
  <p>I have seen some solutions that suggest to use negative paddings but it is not an elegant solution. There should be a better one.</p>
  
  <p>I tried similar configurations on an <code>ImageView</code> too, but it also had extra padding. So it's not an <code>ImageButton</code> specific problem (i.e. it is not related to <a href="https://stackoverflow.com/a/14105941/7491770">this</a> nine-patch issue).</p>
  
  <p>EDIT: If I change <code>scaleType</code> from <code>fitCenter</code> to <code>fitStart</code>, then the outcome is like <a href="https://i.stack.imgur.com/3g5vD.png" rel="nofollow noreferrer">this</a>. So there is somehow a minimum width.</p>