Mr X
Mr X

Reputation: 1063

Android - drawable with rounded corners at the top only not work below-v14

I am trying to make dialog with round corner button. but it's not working below API_LEVEL14

I am trying this but there is no solution. If you have any solution for below api-14 then share it.

for below API 14 it's show like

enter image description here

and it's works well api level 14 and above

enter image description here

for right_below_corner.xml

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

    <item android:state_enabled="false"><shape android:shape="rectangle">
            <solid android:color="@color/header_bg_disable" />
            <corners android:topLeftRadius="0dp" />
            <corners android:topRightRadius="0dp" />
            <corners android:bottomLeftRadius="0dp" />
            <corners android:bottomRightRadius="10dp" />
            <stroke android:width="1dp" android:color="@color/header_bg_disable" />
            <padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
        </shape></item>
    <item android:state_pressed="true"><shape android:shape="rectangle">
            <solid android:color="@color/header_bg_press" />
            <corners android:topLeftRadius="0dp" />
            <corners android:topRightRadius="0dp" />
            <corners android:bottomLeftRadius="0dp" />
            <corners android:bottomRightRadius="10dp" />
            <stroke android:width="1dp" android:color="@color/header_bg_press" />
            <padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
        </shape></item>
    <item android:state_pressed="false"><shape android:shape="rectangle">
            <solid android:color="@color/header_bg" />
            <corners android:topLeftRadius="0dp" />
            <corners android:topRightRadius="0dp" />
            <corners android:bottomLeftRadius="0dp" />
            <corners android:bottomRightRadius="10dp" />
            <stroke android:width="1dp" android:color="@color/header_bg" />
            <padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
        </shape></item>

</selector>

and for bottom_left_corner.xml is

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true"><shape android:shape="rectangle">
            <solid android:color="@color/header_bg_press" />
            <corners android:bottomLeftRadius="10dp" />
            <corners android:topLeftRadius="0dp" />
            <corners android:topRightRadius="0dp" />
            <corners android:bottomRightRadius="0dp" />
            <stroke android:width="1dp" android:color="@color/header_bg_press" />
            <padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
        </shape></item>
    <item android:state_pressed="false"><shape android:shape="rectangle">
            <solid android:color="@color/header_bg" />
            <corners android:topLeftRadius="0dp" />
            <corners android:topRightRadius="0dp" />
            <corners android:bottomRightRadius="0dp" />
            <corners android:bottomLeftRadius="10dp" />
            <stroke android:width="1dp" android:color="@color/header_bg" />
            <padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
        </shape></item>
</selector>

Upvotes: 2

Views: 1738

Answers (1)

Oleg Cherr
Oleg Cherr

Reputation: 3685

Yes, there is a bug in Android up until version 3.1. When specifying the corners separately, the bottom left and right corners get flipped: http://code.google.com/p/android/issues/detail?id=9161

The only solution is to make separate xml-files for those 2 versions. Like this:

res/drawable/corners.xml – with the reversed values

res/drawable-v12/corners.xml – with the normal values

Upvotes: 1

Related Questions