创建自定义绘制对象,并使用它以XML自定义、它以、对象、XML

2023-09-05 05:58:04 作者:盛夏。smile

我忙于创建 NinePatchDrawable 的那么复杂版本的瓷砖伸展它们的内板代替。

I am busy creating a less complicated version of NinePatchDrawable that tiles the inner panels instead of stretching them.

我可以实现实际的逻辑做渲染和这样的。

I can implement the actual logic to do the rendering and such.

不过,我找不到有关如何使用该绘制对象在XML文件中的文档。这可能吗?也就是说,我可以有一个<平铺九个补丁> ,或一些这样的,标签,我可以用它来定义资源

However, I can't find documentation about how to use this Drawable in the XML files. Is this possible? That is, can I have a <tileable-nine-patch>, or some such, tag I can use to define resources?

推荐答案

不幸的是,不可能使用在XML文件中的定制可绘制由于潜在的安全问题。请参见这里了谷歌论坛主题关于这个题目与罗曼盖伊的响应,之一的Andr​​oid开发者。

Unfortunately it is not possible to use custom drawables in XML files due to potential security issues. See here for a Google Groups thread about this very topic with a response from Romain Guy, one of the Android developers.

您仍可以使用,虽然它们在Java code。

You can still use them in your Java code though.