【问题标题】:Referring to resource for Shape Drawable stroke width参考Shape Drawable笔画宽度的资源
【发布时间】:2012-01-16 07:24:48
【问题描述】:

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

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

其中 someWidth 在 strings.xml 中定义为

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

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

android:width="5dp"

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

【问题讨论】:

    标签: android android-layout


    【解决方案1】:

    尝试使用dimension resources

    在您的 values 文件夹中创建一个 dimens.xml 文件,其中包含以下内容:

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

    您可以使用@dimen/some_width 参考此内容。

    【讨论】:

    • uggh,你是对的,我应该看到的。对不起,新手。
    猜你喜欢
    • 1970-01-01
    • 2014-04-13
    • 1970-01-01
    • 2021-09-26
    • 1970-01-01
    • 2018-07-21
    • 1970-01-01
    • 2011-12-05
    • 1970-01-01
    相关资源
    最近更新 更多