Reputation: 1055
When I set android:textSize
as a hard string e.g. 50dp my program works great, but if I save this size in strings.xml and use it like android:textSize="@string/my_size"
I get many of errors.
Could anybody tell me what am I doing wrong?
Upvotes: 2
Views: 1222
Reputation: 6736
instead of using strings.xml to store values you should rather use res/values/dimens.xml to store values for the text size like this:
<dimen name="txtsize">50sp</dimen>
NOTE: instead of using dp you should use sp for text size.
Upvotes: 1
Reputation: 5672
In dimens.xml write
<dimen name="my_size">16sp</dimen>
and use:
android:textSize="@dimen/my_size"
Upvotes: 2
Reputation: 4784
You should put the value in dimens.xml NOT in strings.xml.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="font_size">50dp</dimen>
</resources>
Upvotes: 0