开发者

Using @string resource inside a style definition

I have something like the following (shown below) defined in my styles.xml file. But Android crashes due to the use of the @string/fontExtraLarge. I'm assuming it's because of the order of definition, but is this legal.

I could use the style 'parent' attribute to resolve this, but for only one style definition doesn't make sense. Is there a way to resolve this problem.

BTW, the error I get is Unable to Inflate XML which points to the layout.XML, but really this file is causing this issue.

<!-- **** FONT SIZES **** -->
<string name="fontExtraLarge">20sp</string>
<string name="fontLarge">18sp</string>
<string name="fontMedium">16sp</string>
<string name="fontSmall">10sp</string>
<string name="fontNormal">1开发者_Go百科0sp</string>'

<style name="screenHeader">
    <item name="android:layout_width">fill_parent</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:textStyle">bold</item>
    <item name="android:typeface">serif</item>
    <item name="android:textSize">@string/fontExtraLarge</item>
    <item name="android:textColor">@color/white</item>
    <item name="android:gravity">center</item>
</style>


You should use the dimens.xml file for dimension values

then reference it @dimen/yourDimensionName

More details here


All strings go inside res/values/strings.xml.

Also all style tags have to be enclosed with the <resources/> tag.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜