为什么9补丁在我的应用程序中根本不起作用?

时间:2012-06-04 13:52:15

标签: android imageview nine-patch stretch

我目前正在尝试在我的应用中使用9张补丁图片。

图像非常清晰,并且在SDK提供的图形工具中运行良好:

图片是这样的:

enter image description here

并且该工具似乎工作正常:

enter image description here

不幸的是,使用如此简单的布局,设备上的渲染效果不佳,而9补丁根本不起作用:

<TextView
    android:id="@+id/platenumber"
    android:background="@drawable/plate_fr"
    android:layout_width="320dip"
    android:layout_height="wrap_content" />

对我做错了什么的想法?

enter image description here

修改

我的照片名为* .9.png

enter image description here

3 个答案:

答案 0 :(得分:11)

黑线必须是全黑(RGB:#000000),黑线周围的透明区域完全透明。

答案 1 :(得分:5)

9补丁图片的扩展名应以 .9.png 结尾,否则将被视为普通图片

答案 2 :(得分:3)

检查图像的所有四边上是否至少一个黑色像素