3

I have created the following Nine-Patch PNG Image

enter image description here

but when I add it as a background for a button I have got the following result :

enter image description here

as you can see the picture not fill all the button Background !

here is the XML Layout File :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <Button android:id="@+id/btn" android:layout_width="match_parent" android:layout_height="100dp" android:background="@drawable/ninepatchimage" android:text="Click ME" /> </LinearLayout> 

can any one tell me why ??

2 Answers 2

6

Looking at the image it appears that the image ins't being parsed as a 9patch, it should be saved as img.9.png if not it will appear as a normal image

Like this:

enter image description here

Sign up to request clarification or add additional context in comments.

6 Comments

Maybe try without the padding
the selected image is saved as img.9.png, but when I add it to Project as Icon Set Image, I checked the name of image and it was img.png in Drawable folders !!! is the problem here ???
Yeah, it needs to be like the image above
You can drag the image directly into the folder
Ok I will try that :) but in which Drawable folder should I drag the picture into ??
|
0

Nowadays in AndroidStudio, you can just take any image from the resources and right-click it and choose "Create 9-Patch file" and then configure it using the built in 9-Patch editor, as expained here.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.