android - 如何正确使用九贴图

标签 android nine-patch

我想创建某种像那样的行图像

enter image description here

但我希望它随屏幕尺寸和密度缩放。所以读这个http://developer.android.com/guide/developing/tools/draw9patch.html还有这个http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch我开始创建一个九补丁图像。

但是当我导入它并在我的 android 项目中使用它时,它看起来像那样

enter image description here

如您所见,使用 draw 9 补丁工具绘制的黑色小线仍然可见。为什么?

这是9.png图片

enter image description here

最佳答案

你用的是sdk自带的draw9patch工具吗?它非常方便。
无论如何:

  • 重要的是除了黑色像素之外的每个像素都完全 透明。
  • 黑色像素应该在绝对顶部/底部/左侧/右侧 图片。
  • 图像应命名为 filename.9.png。

关于android - 如何正确使用九贴图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8563435/

相关文章:

java - ADMOB:无法实例化以下类:- com.google.android.gms.ads.AdView

javascript - 将 Google 云端硬盘内容流式传输到 Chromecast

android - 9-patch 图像看起来像素化

android - 带有 9-patch 文件的 Eclipse 错误?

android - 将 9png 图像放入哪个文件夹?

android - 有什么理由不在 Fragment.onCreateView() 的 Fragment View 中将监听器附加到小部件?

java - Android java的正则表达式提取数字和特定符号

android - Buck - 名称 'project_config' 未定义。如何解决?

android - 使用 android 9 补丁文件不工作

android - 带有 9-patch 的 TransitionDrawable - 边距错误