9patch border issues
Is there a trick to making 9patch images with single pixel borders?
I'm not talking about the single pixel black borders that you use to define the stretchable and content areas. I'm talking about the image itself. If I create an image that has a 1 pixel border around it, often times android will pick one of the edges and stretch it to 2 (or sometimes more) pixels, even though I specifically left the edges out of the stretchable area in the draw9patch utility.
Here is a screenshot of what I mean; in this screenshot I've got two buttons in a vertical LinearLayout with the same background image. The top button ob开发者_如何学Goviously has a thicker border, though it shouldn't.
http://www.vimtips.org/media/button_ss.png
Here is a closeup of the screenshot button (on the left) and the actual 9patch image (on the right).
http://vimtips.org/media/images/buttoncmp.png
Buttons are not the only place I've seen this. If I create a background image with a 1 pixel border and use it as the background for ListView rows, sometimes the border appears to be 2pixels instead of just 1.
It's hard to get a UI to look exactly how you want it with these problems. There's got to be a way to get it to appear how you think it should.
Try with diffrent markers in your 9-patch. Ex. like they use in this example: http://developer.android.com/intl/de/guide/developing/tools/draw9patch.html
I have experienced this myself, than the problem was related with my largeScreen support in the manifest file. And I had not provided correct images in the drawable-hdpi folder etc. Resulting the device scaling the drawable-mdpi drawables.
How many drawable folders do you have?
Do you have this in your manifest ? :
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizable="true"
android:anyDensity="true" />
Make sure you have correct drawables for correct density
精彩评论