有什么方法可以在构建时将 XSL 样式表应用于 res/layout/中的布局 XML 文件,以便资源编译器只看到转换后的输出,而不是硬盘驱动器上的实际文件?
为什么:layout_width 和 layout_height 没有默认值,一切都需要它们,并为每个手动指定它们。单例的。小部件。是。慢慢地。驾驶。我。疯了。
所以...我想到的想法是使用 XSLT 自动透明地将值为“wrap_content”的 layout_width 和 layout_height 属性添加到构建时缺少它们的任何标记。我会很高兴,ADT 永远不会知道其中的区别。 :-)
最佳答案
Is there any way to apply an XSL stylesheet to the layout XML files in res/layout/ at build time so the resource compiler sees only the transformed output instead of the actual files on the hard drive?
自定义您的 Ant build.xml
文件以执行您想要的任何操作。 Ant 甚至有一个您可以尝试使用的 xslt
任务。
layout_width and layout_height have no default, everything requires them
他们有时有默认值,这取决于他们的 parent 。 TableLayout
分别为所有子级提供 fill_parent
和 wrap_content
的宽度和高度。 TableRow
为所有子项提供宽度和高度的 wrap_content
。如果需要,可以在您的布局 XML 文件中覆盖这些默认值。
关于android - 在构建时将 XSL 应用于布局 XML?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4360531/