I want to be able to store a font size (18sp) in a resource so that a lot of my layouts will use so that I can easily change the size in the future if I need to. I've a string in a string resource file with "18sp" as the value, and I can call it in the layout editor by setting the text size to "@strings/string_name". At that point everything is fine, and the text is changed to the correct font. The problem is once I try to test that on an actual device I get :
04-13 12:01:01.210: E/AndroidRuntime(17114): Caused by: android.view.InflateException: Binary XML file line #50: Error inflating class <unknown>
04-13 12:01:01.210: E/AndroidRuntime(17114): at
android.view.LayoutInflater.createView(LayoutInflater.java:606)
04-13 12:01:01.210: E/AndroidRuntime(17114): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
04-13 12:01:01.210: E/AndroidRuntime(17114): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
04-13 12:01:01.210: E/AndroidRuntime(17114): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
04-13 12:01:01.210: E/AndroidRuntime(17114): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
04-13 12:01:01.210: E/AndroidRuntime(17114): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
04-13 12:01:01.210: E/AndroidRuntime(17114): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
04-13 12:01:01.210: E/AndroidRuntime(17114): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
04-13 12:01:01.210: E/AndroidRuntime(17114): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
04-13 12:01:01.210: E/AndroidRuntime(17114): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
04-13 12:01:01.210: E/AndroidRuntime(17114): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
04-13 12:01:01.210: E/AndroidRuntime(17114): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
04-13 12:01:01.210: E/AndroidRuntime(17114): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
04-13 12:01:01.210: E/AndroidRuntime(17114): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
04-13 12:01:01.210: E/AndroidRuntime(17114): at android.app.Activity.setContentView(Activity.java:1835)
04-13 12:01:01.210: E/AndroidRuntime(17114):
04-13 12:01:01.210: E/AndroidRuntime(17114): at android.app.Activity.performCreate(Activity.java:4465)
04-13 12:01:01.210: E/AndroidRuntime(17114): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-13 12:01:01.210: E/AndroidRuntime(17114): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
04-13 12:01:01.210: E/AndroidRuntime(17114): ... 11 more
04-13 12:01:01.210: E/AndroidRuntime(17114): Caused by: java.lang.reflect.InvocationTargetException
04-13 12:01:01.210: E/AndroidRuntime(17114): at java.lang.reflect.Constructor.constructNative(Native Method)
04-13 12:01:01.210: E/AndroidRuntime(17114): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
04-13 12:01:01.210: E/AndroidRuntime(17114): at android.view.LayoutInflater.createView(LayoutInflater.java:586)
04-13 12:01:01.210: E/AndroidRuntime(17114): ... 29 more
04-13 12:01:01.210: E/AndroidRuntime(17114): Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x3
04-13 12:01:01.210: E/AndroidRuntime(17114): at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
04-13 12:01:01.210: E/AndroidRuntime(17114): at android.widget.TextView.<init>(TextView.java:786)
04-13 12:01:01.210: E/AndroidRuntime(17114): at android.widget.TextView.<init>(TextView.java:442)
Is this because I am using a string resource as a text size, or would it be some other underlying problem? If it is because i am using a string resource, is there a different / more proper way to have a global text size that I can call on so that I can change everything by modifying 1 value?
Also to note: My app worked just fine before I tried using a string resource as a text size, so I'm relatively certain it can't be something unrelated that is causing the error.
THanks!