title: Why button gets bigger when the background is set in android
body: <p>I encountered a problem with the <code>Button</code> view when I set a background to it using the <code>android:background</code> attribute in xml. Before I set the background, the button has its default size. But when I apply a color as a background, it is getting bigger, even though I did not set a different <code>width</code> or <code>height</code> on it. </p>
  
  <blockquote>
    <p>This is my xml layout before I set background attribute to button</p>
  </blockquote>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
      &lt;Button
          android:background="@color/white"
          android:layout_gravity="center_horizontal"
          android:id="@+id/btn_row_option_done"
          android:text="Done"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  
      &lt;Button
          android:background="@color/white"
          android:layout_gravity="center_horizontal"
          android:text="Edit"
          android:id="@+id/btn_row_option_edit"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  
      &lt;Button
          android:layout_gravity="center_horizontal"
          android:text="Delete"
          android:id="@+id/btn_row_option_delete"
          android:background="@color/red"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  
      &lt;Button
          android:layout_gravity="center_horizontal"
          android:text="Cancel"
          android:id="@+id/btn_row_option_cancel"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <blockquote>
    <p>So the cancel button is default size like in screenshot.</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/mFe5a.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mFe5a.png" alt="enter image description here"></a></p>
  
  <p>But when I set a color on the cancel button like this</p>
  
  <pre><code> &lt;Button
          android:background="@color/white"
          android:layout_gravity="center_horizontal"
          android:text="Cancel"
          android:id="@+id/btn_row_option_cancel"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  </code></pre>
  
  <p>Then the button gets bigger than default size, even though I did not make the width or height bigger.</p>
  
  <blockquote>
    <p>This is the screenshot</p>
  </blockquote>
  
  <p>As you can see above the cancel button became bigger. Actually I am setting background color. How can I fix it to get the default size even after I set the background color?</p>
  
  <p><a href="https://i.stack.imgur.com/QAmG6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/QAmG6.png" alt="enter image description here"></a></p>