参考Shape Drawable笔划宽度的资源

时间:2012-01-15 23:10:48

标签: android android-layout

Eclipse可以在包含以下内容时呈现我的布局:

...
<shape>
...
<stroke>
...
android:width="@strings/someWidth"

其中someWidth在strings.xml中定义为

<string name="someWidth">5dp</string>

但它在真实设备上崩溃,只有在我使用直接字符串时才有效,例如:

android:width="5dp"

如何将笔资源用于笔划宽度?

1 个答案:

答案 0 :(得分:1)

尝试使用dimension resources

使用以下内容在您的values文件夹中创建一个dimens.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <dimen name="some_width">5dp</dimen>
</resources>

您可以使用@dimen/some_width来引用此内容。

相关问题