Using the @string resource inside a style definition

I have something like the following (shown below) defined in styles.xml. But Android crashes due to using @ string / fontExtraLarge. I guess this is due to the order of determination, but whether it is legal.

I could use the "parent" attribute for this, but just to define one style does not make sense. Is there any way to solve this problem.

By the way, the error I get is - It is not possible to inflate XML, which points to layout.XML, but really this file causes this problem.

<!-- **** 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">10sp</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> 
+4
source share
2 answers

You should use the file dimensions.xml for size values

then link to it @ dimen / yourDimensionName

More here

+3
source

All lines go to res / values ​​/strings.xml.

Also, all style tags must be enclosed in the tag <resources/> .

0
source

Source: https://habr.com/ru/post/1345138/


All Articles