Note that there are some explanatory texts on larger screens.

plurals
  1. PONine Patch Drawable Being Clipped
    primarykey
    data
    text
    <p>I'm at a bit of a loss with this one, I have a nine patch drawable (See attached) which works in the draw9Patch tool, has no bad patches, works fine on initial loading of the application for ldpi, mdpi, hdpi 1.6 - 2.3.3.</p> <p>But on each screen size if I go to another activity and then back to the original screen containing the button with the nine patch drawable as it's background, the image is cropped at the top (looks as though it's occurring at the repeatable area).</p> <p>I've gone through the layout an altered any nine patch drawable used to ensure it's not one rogue nine patch causing the issue with the rest. I've ensured that each density pixel screen has it's own set of resources and I'm about to try moving the xml state selectors for the button into each of the respective drawable folders as well.</p> <p>The frustrating thing is that even if the nine patches draw incorrectly, rotating the screen seems to fix the problem, it's only when I move from a new activity back to the problem activity, the nine patches clip 50% of the time.</p> <p>The Drawable is:</p> <p><img src="https://i.stack.imgur.com/4hkO0.png" alt="Problem Nine Patch"></p> <p>The left portion of the resulting image is as follows (Notice there is no rounded edge):</p> <p><img src="https://i.stack.imgur.com/ZUUzB.png" alt="Rendered problem nine patch"></p> <p>If you actually zoom in on the rendered image, it appears to have the top of the nine patch (above the scaled pixel) overlapping the drawable underneath (zoom in and you see the round corner).</p> <p>The layout for the button has nothing unusual about it:</p> <pre><code>&lt;Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:text="@string/some_text"&gt;&lt;/Button&gt; </code></pre> <p>I can set the layout_height to a fixed height (i.e. 50dp) and this seems to stop the nine patch collapsing on itself / clipping.</p> <p>If anyone has any ideas at all as to what the problem could be please let me know.</p> <p>Cheers, Matt</p> <p>Solution:</p> <p>My problem was to do with the following boolean parameters in the state list selector:</p> <p>android:constantSize="true" android:dither="false" android:variablePadding="false" </p> <p>I'm not sure what caused the behaviour, but I assume it causes some form of caching or some optimisation that introduced this intermittent bug.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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