I am attempting to create a custom android “style” xml. And while everyone else I see out there seems to be using ints, it wont even compile:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="DialogStyle"
parent="android:style/Theme.Dialog"
>
<item name="android:background">@color/ReliantCyan</item>
<item name="android:radius">6</item>
<item name="android:textColor">@color/White</item>
</style>
</resources>
gets me:
.../dialogStyle.xml:7: error: Error: Integer types not allowed (at 'android:radius' with value '6').
I have also tried 6pd and 6px but then it says no strings allowed. What am I doing wrong here?
(any accepted answer must be android 2.2 compatible.)
I have now also tried:
<dimen name="dRadius">10pd</dimen>
and then
<item name="android:radius">@dimen/dRadius</item>
but I get a very similar error:
... error: Error: String types not allowed (at 'dRadius' with value '10pd').
I can’t explain this behavior, exactly. Specifying
<item name="android:radius">6dp</item>should be enough.However, to work around this, we can add a dimension resource (within the same file, even, as long as it’s outside of the
styletag), then use that via@dimen.Something like this:
Make sure to specify it as
6dp(6pxshould work also), not6or6pdor any variant thereof.