gpt4 book ai didi

android - dimen.xml 还是dimen.xml?

转载 作者:IT王子 更新时间:2023-10-28 23:37:05 41 4
gpt4 key购买 nike

我通常将尺寸存储在 dimen.xml 文件中。但是,IntelliJ IDEA 的智能感知将维度放入文件 dimens.xml

现在,如果我将尺寸放入文件 dimens.xml 中,Eclipse 将如何处理呢?

我看到文档允许使用这两个文件。如果项目将由 Eclipse 和 IDEA 用户使用,应该使用哪一个

最佳答案

文件本身的名称并不重要,但是有一些建议。来自 docs (关于资源/值):

Because each resource is defined with its own XML element, you can name the file whatever you want and place different resource types in one file. However, for clarity, you might want to place unique resource types in different files. For example, here are some filename conventions for resources you can create in this directory:

  • arrays.xml for resource arrays (typed arrays).
  • colors.xml for color values
  • dimens.xml for dimension values.
  • strings.xml for string values.
  • styles.xml for styles.

编辑:为清楚起见,重要的部分是您在 <dimen> 中使用适当的元素(在本例中为 <resource>)在您的文件中添加标签。这就是android知道它是一个维度资源的方式。

<resources>
<dimen name="my_dimen">10dip</dimen>
</resources>

关于android - dimen.xml 还是dimen.xml?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8940940/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com