Switching bottom Left radius and bottom Right corner issue in android.

During the development of Facebook Scheduler app , i face a amazing problem of switching bottom Left and bottom Right corner while using corners tag with in xml to make edge corner of drawable some what like rounded. This is a kind of bug in android 2.x platform which is already fixed in android 3.x platform. Now problem is How to cope up with this problem in android 2.x and android 3.x. (if I use correct convention for android 3.x then corner will not be as expected in android 2.x device and vice-versa).

Here is the procedure how i escape from this problem.
1) make separate drawable (lets say bottonPressedLeft.xml) for app running in android device 2.x.x. and place in the drawable folder.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

     <gradient 
        android:angle="-270" 
        android:endColor="#F0C37E"
        android:startColor="#F0C37E"/>

    <corners 
        android:bottomLeftRadius="0dp" 
        android:bottomRightRadius="5dp" 
        android:topLeftRadius="5dp" 
        android:topRightRadius="0dp"></corners>

</shape>

Above drawable is for making topleft and bottomleft rounded with radius for running in android 2.x.x device.(bug)
Note location of xml file : res/drawable/bottonPressedLeft.xml

2)make another drawable with the same name for app running in android 3.x.x device and (make a folder with name res/drawable-v12 ) place in it.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

     <gradient 
        android:angle="-270" 
        android:endColor="#F0C37E"
        android:startColor="#F0C37E"/>

    <corners 
        android:bottomLeftRadius="0dp" 
        android:bottomRightRadius="5dp" 
        android:topLeftRadius="5dp" 
        android:topRightRadius="0dp"></corners>

</shape>

Above drawable is for making topleft and bottomleft rounded with radius for running in android 3.x.x device.(bug fixed case)
Note location of xml file : res/drawable-v12/bottonPressedLeft.xml.

If your app is running under android 2.x.x device then it will use the res/drawable/bottonPressedLeft.xml file and if your app is running under android 3.x.x device then will use res/drawable-v12/bottonPressedLeft.xml

Hope this helps someone somewhere in some point of time 🙂

Advertisements