android - 在构建时将 XSL 应用于布局 XML?

标签 android android-widget android-layout

有什么方法可以在构建时将 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_parentwrap_content 的宽度和高度。 TableRow 为所有子项提供宽度和高度的 wrap_content。如果需要,可以在您的布局 XML 文件中覆盖这些默认值。

关于android - 在构建时将 XSL 应用于布局 XML?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4360531/

相关文章:

java - 如何设计适合整个屏幕的网格布局?

android - ScrollView中的最小高度fill_parent和高度wrap_content? (或者只是电子邮件应用程序编写布局的代码)

java - 显示 imageview onclick 并发布,如果为空则不显示 imageview

android - HTTP Live Streaming 中的时间戳不连续问题

java - 小部件未更新?

android - BLE connectGatt() 方法未在 BluetoothGattCallback 中报告任何内容....?

android - 在 LinearLayout 上实现 OnTouchListener - Android 开发

java - Android TextView 在从右到左的设备上右对齐

Android NDK -stdio.h : sys/cdefs. h 未找到

java - android studio图像按钮单击时更改src