5

I'm trying to have a shape drawable with this shape:

enter image description here

This works properly in 1.6 to 2.3.5 when using the following:

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
 android:shape="rectangle"> 
<solid android:color="#cc6900"/>

<corners android:radius="0.1dp" android:bottomRightRadius="7dp" android:bottomLeftRadius="0dp"
 android:topLeftRadius="0dp" android:topRightRadius="7dp"/> 

However, when running it on a Galaxy Nexus, or a 4.0 Emulator, I have to use this to get the same layout:

...
<corners android:radius="0.1dp" android:bottomRightRadius="0dp" android:bottomLeftRadius="7dp"
 android:topLeftRadius="0dp" android:topRightRadius="7dp"/> 
...

Which gives me this on 1.6:

enter image description here

So basically, previous versions has all used bottomRight and bottomLeft in one way, and now 4.0 does it in another.

Is there any easy way that I can have it be like it is for pre 4.0, and give 4.0 users the changed values? If possible, I'd prefer if I could keep it in XML and not have it in code.

Joakim Berglund
  • 2,859
  • 1
  • 22
  • 30

1 Answers1

12

Hm, looks like we broke bug compatibility when we fixed that one. ;)

Since you're defining this in an XML drawable, include the version that works before Android 4.0 in your res/drawable/ directory and the one that works on Android 4.0+ in another directory called res/drawable-v14/. (14 is the API level of Android 4.0.) Devices running Android 4.0 and newer will use the newer version.

You can use this same technique to have the system auto-select the correct resource for a bunch of different configuration options, see here for more info: http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources

adamp
  • 28,862
  • 9
  • 81
  • 69