I have created the following Nine-Patch PNG Image
but when I add it as a background for a button I have got the following result :
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 ??
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:
9-patch could solve ur problem here: http://developer.android.com/guide/developing/tools/draw9patch.html
and search for "Nine-patch" here: http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch
如今在AndroidStudio,你可以采取任何图像从资源,然后右键单击它并选择“创建9补丁文件”,然后使用内置的9补丁编辑器进行配置,如expained 这里 。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.