title: Extra padding when using Optical Bounds in background image
body: <p>The optical bounds feature introduced in <a href="https://developer.android.com/about/versions/android-4.3.html#UI" rel="nofollow noreferrer">https://developer.android.com/about/versions/android-4.3.html#UI</a> seems to add an additional padding setting to the parent layout.
  In the screenshot below, 3 example fragments can be seen:</p>
  
  <ol>
  <li>A fragment with the default setting layoutMode="clipBounds"</li>
  <li>A fragment with layoutMode="opticalBounds"</li>
  <li>A fragment with layoutMode="opticalBounds", but the background image is a simple color.</li>
  </ol>
  
  <p>Fragment #2 has a additional padding in the root layout. My goal is to remove that padding, so that I can place &amp; layout the TextView entirely based on it's inner optical bounds.</p>
  
  <p>How can I remove the inner padding created by the 2nd fragment? I have already tried setting the padding to 0dp or "-11dp" but this is not what I hope on doing.</p>
  
  <p>Thanks for any suggestions. </p>
  
  <p>Code:</p>
  
  <h3>Fragment 1:</h3>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
               android:layout_width="match_parent"
               android:layout_height="match_parent"
               android:orientation="vertical"
               android:paddingLeft="20dp"
               android:paddingTop="20dp"&gt;
  
      &lt;TextView
          android:layout_width="200dp"
          android:layout_height="200dp"
          android:background="@drawable/shadow_with_stroke_gray"
          android:text="lorem ipsum etc"
          android:padding="20dp"
          /&gt;
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <h3>Fragment 2:</h3>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
               android:orientation="vertical"
               android:layout_width="match_parent"
               android:layout_height="match_parent"
               android:layoutMode="opticalBounds"
               android:paddingLeft="20dp"
               android:paddingTop="20dp"&gt;
  
      &lt;TextView
          android:layout_width="200dp"
          android:layout_height="200dp"
          android:background="@drawable/shadow_with_stroke_gray"
          android:text="lorem ipsum etc"
          android:padding="20dp"
          /&gt;
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <h3>Fragment 3</h3>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
               android:orientation="vertical"
               android:layout_width="match_parent"
               android:layout_height="match_parent"
               android:layoutMode="opticalBounds"
               android:paddingLeft="20dp"
               android:paddingTop="20dp"&gt;
  
      &lt;TextView
          android:layout_width="200dp"
          android:layout_height="200dp"
          android:background="#ffffcc"
          android:text="lorem ipsum etc"
          android:padding="20dp"
          /&gt;
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <h3>Activity Layout</h3>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:id="@+id/container"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:padding="40dp"&gt;
  
      &lt;fragment
          android:id="@+id/fragment1"
          android:layout_width="312dp"
          android:layout_height="match_parent"
          class="opticalboundstest.WithoutOpticalBoundsFragment"/&gt;
  
      &lt;Space
          android:layout_width="21dp"
          android:layout_height="match_parent"/&gt;
  
      &lt;fragment
          android:id="@+id/fragment2"
          android:layout_width="312dp"
          android:layout_height="match_parent"
          class="opticalboundstest.WithOpticalBoundsFragment"/&gt;
  
      &lt;Space
          android:layout_width="21dp"
          android:layout_height="match_parent"/&gt;
  
      &lt;fragment
          android:id="@+id/fragment3"
          android:layout_width="312dp"
          android:layout_height="match_parent"
          class="opticalboundstest.WithWorkingOpticalBoundsFragment"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/zQe9D.png" alt="Simulator screenshot"></p>
  
  <p>The shadow image being used:</p>
  
  <p><img src="https://i.stack.imgur.com/8Vnvf.png" alt="Shadow 9-Patch image"></p>