I'm having some trouble using 9patch with the Android SDK in Eclipse IDE (Indigo). I build a 30*25 9Patch image that i want to use as button background.
Now, this 9Patch image, even if it is so small, works great in the IDE at desing-time. Infact, if i change device's screen size, my button resizes very well and the background remains well defined from 2.7" to 10.1" screens.
But when i run my app on a real device or in debug mode (only with device with screen size >= 3.7"), the image looses his quality, and becomes scattered in the same way old MS Paint did when you zoomed to much an image! Like the image in the link above!
I also tried to use bigger 9patch (300*250), but in this way it works only on big screens, while on small screens the button's background resize is terrifying. The text becomes unreadable, the background overlaps and sometimes seems to wrap etc... What the hell is wrong with that? Why in my IDE everything works well while in my app no? I don't want to create different 9patch for each small-medium-large-xlarge and ldpi-mdpi-hdpi-xhdpi combinations screen category...9patch is specificately born to solve this kind of resizing problem....
I post some code about the button in question:
<Button
android:id="@+id/btnStart"
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight=".10"
android:text="@string/btnStartText" >
</Button>
And this is the style applied to the button:
<style name="button_style" parent="android:Widget.Button">
<item name="android:background">@drawable/button_statelistdrawable</item>
<item name="android:textColor">@color/White</item>
<item name="android:textSize">28sp</item>
</style>
Hope someone helps me.... Thanks in advance =)
Your 9-patch is missing the padding-definition area (bottom & right), so it's no valid 9-patch which will most likely explain the display-erros.
I added them in this sample-file: