分配“WRAP_CONTENT”或“-2”维度维度、分配、WRAP_CONTENT

2023-09-07 15:14:28 作者:山河不入梦

我要创造出有等于'WRAP_CONTENT不变。

I want to create a dimension that would be equal to 'wrap_content' constant.

所以,根据developer.android.com参考我写的:

<dimen name="horizontal_border_height">-2</dimen>

但ADT说:

错误:整数类型不允许(在'horizo​​ntal_border_height,值为-2')

Error: Integer types not allowed (at 'horizontal_border_height' with value '-2')

Asigning'WRAP_CONTENT的价值产生错误了。

Asigning 'wrap_content' value generates error too.

我是什么做错了吗?任何想法如何使它工作?

What am I doing wrong? Any ideas how to make it work?

推荐答案

检查出的应用程序资源API指南你可以看到支持联信的尺寸值。不能使用维度传递一个WRAP_CONTENT作为浏览维度。

Check out app resources API guide and you can see supported unites for a dimension value. You can't use dimension to pass a wrap_content as a Views dimension.