A NinePatch is a stretchable bitmap image, which Android will automatically resize to accommodate the contents of the View in which you have placed it as the background. The four corners are unscaled; the four edges are scaled in one axis, and the middle is scaled in both axes.
Questions tagged [nine-patch]
704 questions
84
votes
15 answers
How to change the spinner background in Android?
I am developing an app in which I need to change the spinner background layout to match the background color. I researched and found that I need to create a 9 patch image. I have done creating the 9 patch image and used in the app but it looks…

vinothp
- 9,939
- 19
- 61
- 103
58
votes
14 answers
9-patch image error in Android
Whenever I try to add a 9-patch image to the \drawable folder in my project, I get the same error:
ERROR: 9-patch image C:\...\res\drawable\appwidget.9.png malformed.
Frame pixels must be either solid or transparent (not intermediate alphas).
Found…

Heber
- 581
- 1
- 4
- 5
51
votes
8 answers
Creating & Using 9-patch images in Android
I recently heard about 9-patch images. I know its 9 tiled and is stretchable. I'd like to know more about it.
How can I create a 9-patch image?
Is there any tool? Can I create it from AndroidSDK or code?
Main Advantages of 9-patch over regular…

Nizam
- 5,698
- 9
- 45
- 57
42
votes
8 answers
How to create android spinner without down triangle on the right side of the widget
I have a screen where the user has many items to input so screen space is at a premium.
I want the look of the widget on the screen (before the user presses it) to be similar to an EditText or the left portion of the Spinner widget (without the…

Mike
- 777
- 3
- 7
- 14
41
votes
7 answers
Create a NinePatch/NinePatchDrawable in runtime
I have a requirement on my Android application that parts on the graphics should be customizable, by retrieving new colors and images from the server side. Some of these images are nine-patch images.
I can't find a way to create and display these…

jacob11
- 670
- 1
- 9
- 12
36
votes
3 answers
Android: 9-patch repeat pattern instead of stretching
I have a 9-patch image file which looks like this:
When I use it it appears like this:
What I actually wanted to achieve is the complete dot in the center repeated instead of stretched. I hope that it's possible.

znq
- 44,613
- 41
- 116
- 144
35
votes
2 answers
How to return to default style on EditText if I apply a background?
I just encountered with a problem that I don't know how to solve. It looks silly but I cannot find a way to fix it.
I have a form in android with several EditText and when you submit the form it checks those EditText and if they have wrong data I…

SERPRO
- 10,015
- 8
- 46
- 63
31
votes
2 answers
Android 9 Patch tool: What is the new layout bounds feature?
I've updated r20 of the Android SDK and started the 9 Patch tool.
There seems to be a new feature - Holding Control and clicking adds layout bounds which are referred to as red pixels.
I've taken a look at the documentation but it seems out of…

Brad
- 9,113
- 10
- 44
- 68
30
votes
4 answers
Convert png images to 9 patch in Android Studio
In android studio,you can edit 9 patches directly from with the IDE. But is it also possible to convert an png image to 9-patch using the IDE? (similar to the android 9-patch tool provided by the SDK).

user2392650
- 303
- 1
- 3
- 4
30
votes
4 answers
How to use 9-patch images in IOS?
I want to use 9-patch images in my IOS app. Is it possible?

Adams
- 387
- 1
- 3
- 5
27
votes
2 answers
Different 9-patch images for different densities?
I have the same 9-patch images in MDPI / HDPI / xhdpi. Is there a particular reason why it will not be saved for the smallest size? The stretchable areas scale automatically when the content is greater, for example a background as a 9-patch.
Example…

user949884
- 503
- 1
- 8
- 15
27
votes
6 answers
Bad 'Patches' in 9-Patch File
I'm attempting to use the Draw9Patch tool from the Android SDK, but immediately upon opening my image with Draw9Patch it shows all of my image area as a 'Bad Patch.' I manually drew in the lines that define the stretchable areas, however I am unsure…

Nick Betcher
- 2,026
- 5
- 19
- 25
27
votes
4 answers
Is there a nine-patch loader for iPhone?
Android has a nice way of defining stretchable images called a nine-patch. See these docs for a description of the concept. The idea is to surround a png image with a 1-pixel border where you can define the stretchable areas and the padding…

n8gray
- 4,939
- 3
- 36
- 33
25
votes
1 answer
Drawing Nine Patch onto Canvas (Android)
I'm trying to draw a nine patch onto a Canvas object on the Android. What seems strange is that although I generated my nine patch using the draw9patch tool, the constructor for NinePatch requires an additional byte array called the "chunk" to…

Tom R
- 5,991
- 9
- 35
- 41
21
votes
4 answers
Meaning of red color in Android's Nine-patch drawables
According to the Android documentation, we know that the left and top black line define the stretchable area, and the bottom and right line define the content area.
It's easy to understand, but I found the below image named…

chengbo
- 5,789
- 4
- 27
- 41